Skip to content

Commit

Permalink
delete email tokens on email update
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Feb 3, 2024
1 parent 4b1c8af commit ccbb868
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/pds/src/account-manager/helpers/email-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export const deleteEmailToken = async (
)
}

export const deleteAllEmailTokens = async (db: AccountDb, did: string) => {
await db.executeWithRetry(
db.db.deleteFrom('email_token').where('did', '=', did),
)
}

export const assertValidToken = async (
db: AccountDb,
did: string,
Expand Down
2 changes: 1 addition & 1 deletion packages/pds/src/account-manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export class AccountManager {
await this.db.transaction((dbTxn) =>
Promise.all([
account.updateEmail(dbTxn, did, email),
emailToken.deleteEmailToken(dbTxn, did, 'update_email'),
emailToken.deleteAllEmailTokens(dbTxn, did),
]),
)
} else {
Expand Down

0 comments on commit ccbb868

Please sign in to comment.