From ccbb868bbb3bd685a94558805de4381907b3bf8b Mon Sep 17 00:00:00 2001 From: dholms Date: Sat, 3 Feb 2024 16:35:12 -0600 Subject: [PATCH] delete email tokens on email update --- packages/pds/src/account-manager/helpers/email-token.ts | 6 ++++++ packages/pds/src/account-manager/index.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/pds/src/account-manager/helpers/email-token.ts b/packages/pds/src/account-manager/helpers/email-token.ts index 85be5d4b6d0..7d3690ad0e9 100644 --- a/packages/pds/src/account-manager/helpers/email-token.ts +++ b/packages/pds/src/account-manager/helpers/email-token.ts @@ -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, diff --git a/packages/pds/src/account-manager/index.ts b/packages/pds/src/account-manager/index.ts index 1a6a2493fb9..c25e2ba01bc 100644 --- a/packages/pds/src/account-manager/index.ts +++ b/packages/pds/src/account-manager/index.ts @@ -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 {