Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all email tokens on email change #2132

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions packages/pds/src/account-manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,18 +321,14 @@ export class AccountManager {
)
}

async updateEmail(opts: { did: string; email: string; token?: string }) {
const { did, email, token } = opts
if (token) {
await this.db.transaction((dbTxn) =>
Promise.all([
account.updateEmail(dbTxn, did, email),
emailToken.deleteAllEmailTokens(dbTxn, did),
]),
)
} else {
return account.updateEmail(this.db, did, email)
}
async updateEmail(opts: { did: string; email: string }) {
const { did, email } = opts
await this.db.transaction((dbTxn) =>
Promise.all([
account.updateEmail(dbTxn, did, email),
emailToken.deleteAllEmailTokens(dbTxn, did),
]),
)
}

async resetPassword(opts: { password: string; token: string }) {
Expand Down
2 changes: 1 addition & 1 deletion packages/pds/src/api/com/atproto/server/updateEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function (server: Server, ctx: AppContext) {
}

try {
await ctx.accountManager.updateEmail({ did, email, token })
await ctx.accountManager.updateEmail({ did, email })
} catch (err) {
if (err instanceof UserAlreadyExistsError) {
throw new InvalidRequestError(
Expand Down
Loading