-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.config.ts
45 lines (37 loc) · 1 KB
/
auth.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { createClient } from '@supabase/supabase-js';
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
);
export const supabaseAuth = {
signIn: async (email: string, password: string) => {
const { data, error } = await supabase.auth.signInWithPassword({
email,
password
});
if (error) throw error;
return data;
},
signUp: async (email: string, password: string) => {
const { data, error } = await supabase.auth.signUp({
email,
password
});
if (error) throw error;
return data;
},
signOut: async () => {
const { error } = await supabase.auth.signOut();
if (error) throw error;
},
getSession: async () => {
const { data, error } = await supabase.auth.getSession();
if (error) throw error;
return data.session;
},
getUser: async () => {
const { data, error } = await supabase.auth.getUser();
if (error) throw error;
return data.user;
}
};