Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

Commit

Permalink
Look up the supabase auth cookie by its dynamic name
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmaes committed Sep 20, 2023
1 parent 81f5c0b commit 4dcea37
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,18 @@ export const isAcceptingSpaceNatively = (
getRoles(el).includes('button');

export const isSignedIn = () => {
const authCookie = Cookies.get('supabase-auth-token');
return authCookie !== undefined && authCookie.length > 0;
const match = process.env.NEXT_PUBLIC_SUPABASE_API_URL.match(
/https:\/\/(.*)\.supabase/,
);

if (match) {
const supabaseProjectName = match[1];
const cookieName = `sb-${supabaseProjectName}-auth-token`;
const authCookie = Cookies.get(cookieName);
return authCookie !== undefined && authCookie.length > 0;
}

return false;
};

export const isErrorWithMessage = (
Expand Down

0 comments on commit 4dcea37

Please sign in to comment.