From 80deb3732b7a08276cf41938d969f7c07a957a72 Mon Sep 17 00:00:00 2001 From: Daniel Reichhart Date: Mon, 4 Mar 2024 10:21:35 +0100 Subject: [PATCH 1/2] feat: headers for logout --- src/authenticator.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/authenticator.ts b/src/authenticator.ts index 921d2ec..4af069f 100644 --- a/src/authenticator.ts +++ b/src/authenticator.ts @@ -267,16 +267,18 @@ export class Authenticator { */ async logout( request: Request | Session, - options: { redirectTo: string } + options: { redirectTo: string; headers?: HeadersInit } ): Promise { let session = isSession(request) ? request : await this.sessionStorage.getSession(request.headers.get("Cookie")); - throw redirect(options.redirectTo, { - headers: { - "Set-Cookie": await this.sessionStorage.destroySession(session), - }, - }); + const headers = new Headers(options.headers); + headers.append( + "Set-Cookie", + await this.sessionStorage.destroySession(session) + ); + + throw redirect(options.redirectTo, { headers: headers }); } } From 1e1811dcd1e4ce4f63550f08760923ae9d0ca63c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Xalambr=C3=AD?= Date: Thu, 30 May 2024 12:25:53 -0500 Subject: [PATCH 2/2] Apply suggestions from code review --- src/authenticator.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/authenticator.ts b/src/authenticator.ts index 4af069f..243702c 100644 --- a/src/authenticator.ts +++ b/src/authenticator.ts @@ -273,12 +273,12 @@ export class Authenticator { ? request : await this.sessionStorage.getSession(request.headers.get("Cookie")); - const headers = new Headers(options.headers); + let headers = new Headers(options.headers); headers.append( "Set-Cookie", await this.sessionStorage.destroySession(session) ); - throw redirect(options.redirectTo, { headers: headers }); + throw redirect(options.redirectTo, { headers }); } }