Skip to content

Commit

Permalink
fix email request routes for entryway
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Nov 7, 2023
1 parent b654572 commit 5723a73
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function (server: Server, ctx: AppContext) {
handler: async ({ auth, req }) => {
const did = auth.credentials.did
const account = await ctx.accountManager.getAccount(did)
if (!account?.email) {
if (!account) {
throw new InvalidRequestError('account not found')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function (server: Server, ctx: AppContext) {
handler: async ({ auth, req }) => {
const did = auth.credentials.did
const account = await ctx.accountManager.getAccount(did)
if (!account?.email) {
if (!account) {
throw new InvalidRequestError('account not found')
}

Expand Down
23 changes: 11 additions & 12 deletions packages/pds/src/api/com/atproto/server/requestPasswordReset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,24 @@ export default function (server: Server, ctx: AppContext) {

const account = await ctx.accountManager.getAccountByEmail(email)

if (account) {
if (!account?.email) {
if (ctx.entrywayAgent) {
await ctx.entrywayAgent.com.atproto.server.requestPasswordReset(
input.body,
authPassthru(req, true),
)
return
}
if (!account.email) {
throw new InvalidRequestError('account does not have an email address')
}
const token = await ctx.accountManager.createEmailToken(
account.did,
'reset_password',
)
await ctx.mailer.sendResetPassword(
{ identifier: account.handle ?? account.email, token },
{ to: account.email },
)
throw new InvalidRequestError('account does not have an email address')
}

const token = await ctx.accountManager.createEmailToken(
account.did,
'reset_password',
)
await ctx.mailer.sendResetPassword(
{ identifier: account.handle ?? account.email, token },
{ to: account.email },
)
})
}

0 comments on commit 5723a73

Please sign in to comment.