Skip to content

Commit

Permalink
Merge branch 'multi-pds-auth' into signup-queueing-take2
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Feb 4, 2024
2 parents e9783cf + 57b1ad5 commit 3f3df31
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ export default function (server: Server, ctx: AppContext) {
auth: ctx.authVerifier.accessCheckTakedown,
handler: async ({ auth }) => {
const did = auth.credentials.did
const user = await ctx.services.account(ctx.db).getAccount(did)
if (!user) {
throw new InvalidRequestError('user not found')
}
const token = await ctx.services
.account(ctx.db)
.createEmailToken(did, 'confirm_email')
await ctx.mailer.sendConfirmEmail({ token }, { to: user.email })
const { token, email } = await ctx.db.transaction(async (dbTxn) => {
const token = await ctx.services
.account(dbTxn)
.createEmailToken(did, 'confirm_email')
const user = await ctx.services.account(ctx.db).getAccount(did)
if (!user) {
throw new InvalidRequestError('user not found')
}
return { token, email: user.email }
})
await ctx.mailer.sendConfirmEmail({ token }, { to: email })
},
})
}

0 comments on commit 3f3df31

Please sign in to comment.