Skip to content

Commit

Permalink
Make auth cookie name TS constant
Browse files Browse the repository at this point in the history
  • Loading branch information
myieye committed Dec 11, 2023
1 parent 7ec2a8b commit 9fe376b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions frontend/src/lib/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type UserProjects = {
role: UserProjectRole
}
export const USER_LOAD_KEY = 'user:current';
export const AUTH_COOKIE_NAME = '.LexBoxAuth';

export function isAdmin(user: LexAuthUser | null): boolean {
return user?.role === 'admin';
Expand Down Expand Up @@ -90,7 +91,7 @@ export async function register(password: string, name: string, email: string, tu
}

export function getUser(cookies: Cookies): LexAuthUser | null {
const token = getCookie('.LexBoxAuth', cookies);
const token = getCookie(AUTH_COOKIE_NAME, cookies);

if (!token) {
return null
Expand Down Expand Up @@ -141,7 +142,7 @@ function projectsStringToProjects(projectsString: string | undefined): UserProje
}

export function logout(cookies?: Cookies): void {
cookies && deleteCookie('.LexBoxAuth', cookies);
cookies && deleteCookie(AUTH_COOKIE_NAME, cookies);
if (browser && window.location.pathname !== '/login') {
throw redirect(307, '/login');
}
Expand Down

0 comments on commit 9fe376b

Please sign in to comment.