Skip to content

Commit

Permalink
feat: headers for logout
Browse files Browse the repository at this point in the history
  • Loading branch information
reichhartd committed Mar 4, 2024
1 parent 610b485 commit 80deb37
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/authenticator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,18 @@ export class Authenticator<User = unknown> {
*/
async logout(
request: Request | Session,
options: { redirectTo: string }
options: { redirectTo: string; headers?: HeadersInit }
): Promise<never> {
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 });
}
}

0 comments on commit 80deb37

Please sign in to comment.