Clear email tokens on email update ()

delete email tokens on email update
This commit is contained in:
Daniel Holmgren 2024-02-03 16:52:29 -06:00 committed by GitHub
parent 4b1c8af6e3
commit b6b854afb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions
packages/pds/src/account-manager

@ -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,

@ -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 {