Skip to content

Commit

Permalink
Remove removeCookie in favor of setCookie
Browse files Browse the repository at this point in the history
  • Loading branch information
blakewilson committed Feb 20, 2024
1 parent 711aaf9 commit d73c54d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
18 changes: 0 additions & 18 deletions packages/faustwp-core/src/server/auth/cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,4 @@ export class Cookies {

this.response?.setHeader('Set-Cookie', newCookies);
}

public removeCookie(key: string): void {
delete this.cookies[key];

const existingCookieHeader = this.response?.getHeader('Set-Cookie');

const newCookies = mergeCookies(
existingCookieHeader,
cookie.serialize(key, '', {
path: '/',
expires: new Date(0),
secure: true,
httpOnly: true,
}),
);

this.response?.setHeader('Set-Cookie', newCookies);
}
}
8 changes: 7 additions & 1 deletion packages/faustwp-core/src/server/auth/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ export class OAuth {
let expiresIn: Date | undefined;

if (!isString(token) || token.length === 0) {
this.cookies.removeCookie(this.tokenKey);
this.cookies.setCookie(this.tokenKey, '', {
path: '/',
expires: new Date(0),
secure: true,
httpOnly: true,
});

this.cookies.setCookie(this.hasTokenKey, '0', {
path: '/',
encoded: false,
Expand Down

0 comments on commit d73c54d

Please sign in to comment.