Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
alan2207 committed May 3, 2024
1 parent d645507 commit 7bf605e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/test/server/handlers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const authHandlers = [
return HttpResponse.json(result, {
headers: {
// with a real API servier, the token cookie should also be Secure and HttpOnly
'Set-Cookie': `${AUTH_COOKIE}=${result.jwt}; Path=/; SameSite=Strict; Max-Age=3600;`,
'Set-Cookie': `${AUTH_COOKIE}=${result.jwt}; Path=/; Max-Age=3600;`,
},
});
} catch (error: any) {
Expand All @@ -101,7 +101,7 @@ export const authHandlers = [
return HttpResponse.json(result, {
headers: {
// with a real API servier, the token cookie should also be Secure and HttpOnly
'Set-Cookie': `${AUTH_COOKIE}=${result.jwt}; Path=/; SameSite=Strict; Max-Age=3600;`,
'Set-Cookie': `${AUTH_COOKIE}=${result.jwt}; Path=/; Max-Age=3600;`,
},
});
} catch (error: any) {
Expand All @@ -114,7 +114,7 @@ export const authHandlers = [
{ message: 'Logged out' },
{
headers: {
'Set-Cookie': `${AUTH_COOKIE}=; Path=/; SameSite=Strict; Max-Age=0;`,
'Set-Cookie': `${AUTH_COOKIE}=; Path=/; Max-Age=0;`,
},
}
);
Expand Down
2 changes: 1 addition & 1 deletion src/test/server/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const AUTH_COOKIE = `bulletproof_react_app_token`;
export function requireAuth(cookies: Record<string, string>, shouldThrow = true) {
try {
const encodedToken = cookies[AUTH_COOKIE];
console.log({ cookies: Cookies.get(AUTH_COOKIE), encodedToken });
console.log({ cookies, cookie: Cookies.get(AUTH_COOKIE), encodedToken });
if (!encodedToken) {
if (shouldThrow) {
throw new Error('No authorization token provided!');
Expand Down

0 comments on commit 7bf605e

Please sign in to comment.