diff --git a/backend/src/api/controllers/user.ts b/backend/src/api/controllers/user.ts index 3ed967642..b18c19b8d 100644 --- a/backend/src/api/controllers/user.ts +++ b/backend/src/api/controllers/user.ts @@ -25,6 +25,7 @@ import { ObjectId } from "mongodb"; import * as ReportDAL from "../../dal/report"; import emailQueue from "../../queues/email-queue"; import FirebaseAdmin from "../../init/firebase-admin"; +import { removeTokensFromCacheByUid } from "../../utils/auth"; async function verifyCaptcha(captcha: string): Promise { if (!(await verify(captcha))) { @@ -897,5 +898,6 @@ export async function revokeAllTokens( ): Promise { const { uid } = req.ctx.decodedToken; await FirebaseAdmin().auth().revokeRefreshTokens(uid); + removeTokensFromCacheByUid(uid); return new MonkeyResponse("All tokens revoked"); } diff --git a/backend/src/utils/auth.ts b/backend/src/utils/auth.ts index f48bbbed0..697874485 100644 --- a/backend/src/utils/auth.ts +++ b/backend/src/utils/auth.ts @@ -58,3 +58,11 @@ export async function updateUserEmail( emailVerified: false, }); } + +export function removeTokensFromCacheByUid(uid: string): void { + for (const entry of tokenCache.entries()) { + if (entry[1].uid === uid) { + tokenCache.delete(entry[0]); + } + } +} diff --git a/frontend/static/html/pages/settings.html b/frontend/static/html/pages/settings.html index 703ac88e4..a660c53b5 100644 --- a/frontend/static/html/pages/settings.html +++ b/frontend/static/html/pages/settings.html @@ -2900,7 +2900,7 @@ - +