Skip to content

Commit

Permalink
added session helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-Manasse committed Jan 12, 2024
1 parent a1669a2 commit d83f6ce
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions getCurrentSession.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export async function getCurrentSession(supabase, req) {
const cookies = req.headers.cookie;
const access_token = cookies.split('; ')[0].split('=')[1];

const refresh_token = cookies.split('; ')[1].split('=')[1];
const { sessionData, sessionError } = supabase.auth.setSession({
access_token,
refresh_token,
})

if (sessionError) {

console.error('session error', sessionError);

throw sessionError;

}

const {

data: { user },

} = await supabase.auth.getUser();
return supabase;
}
Empty file modified respone.test.ts
100644 → 100755
Empty file.
Empty file modified routes/registration.js
100644 → 100755
Empty file.

0 comments on commit d83f6ce

Please sign in to comment.