auth: add delete auth after flash in case only one is picked up

This commit is contained in:
dswbx
2025-07-05 09:43:14 +02:00
parent b35ee36fb1
commit e939debba5

View File

@@ -342,9 +342,9 @@ export class Authenticator<Strategies extends Record<string, Strategy> = Record<
await setSignedCookie(c, "auth", token, secret, this.cookieOptions); await setSignedCookie(c, "auth", token, secret, this.cookieOptions);
} }
private async deleteAuthCookie(c: Context) { private deleteAuthCookie(c: Context) {
$console.debug("deleting auth cookie"); $console.debug("deleting auth cookie");
await deleteCookie(c, "auth", this.cookieOptions); deleteCookie(c, "auth", this.cookieOptions);
} }
async logout(c: Context<ServerEnv>) { async logout(c: Context<ServerEnv>) {
@@ -353,9 +353,13 @@ export class Authenticator<Strategies extends Record<string, Strategy> = Record<
const cookie = await this.getAuthCookie(c); const cookie = await this.getAuthCookie(c);
if (cookie) { if (cookie) {
await this.deleteAuthCookie(c); addFlashMessage(c, "Signed out", "info");
await addFlashMessage(c, "Signed out", "info");
} }
// on waku, only one cookie setting is performed
// therefore adding deleting cookie at the end
// as the flash isn't that important
this.deleteAuthCookie(c);
} }
// @todo: move this to a server helper // @todo: move this to a server helper