1+ 'use server'
2+
3+ import { revalidatePath } from 'next/cache'
4+ import { redirect } from 'next/navigation'
5+ import { createClient } from '@/utils/supabase/server'
6+ // import { signinSchema } from '@/validations/validation'
7+
8+ // export async function login(data: { email: string, password: string }) {
9+ // const supabase = await createClient()
10+ // const { success, error } = signinSchema.safeParse(data);
11+ // if (!success) {
12+ // console.log(error);
13+ // return;
14+ // }
15+ // // const data = {
16+ // // email: formData.get('email') as string,
17+ // // password: formData.get('password') as string,
18+ // // }
19+ // const { error: signInError } = await supabase.auth.signInWithPassword(data)
20+ // if (signInError) {
21+ // console.log(signInError);
22+ // return
23+ // }
24+
25+ // revalidatePath('/', 'layout')
26+ // redirect('/dashboard');
27+ // }
28+
29+ // export async function signup(formData: FormData) {
30+ // const supabase = await createClient()
31+ // const data = {
32+ // email: formData.get('email') as string,
33+ // password: formData.get('password') as string,
34+ // }
35+
36+ // const { error } = await supabase.auth.signUp(data)
37+
38+ // if (error) {
39+ // redirect('/error')
40+ // }
41+
42+ // revalidatePath('/', 'layout')
43+ // redirect('/')
44+ // }
45+
46+ export async function signout ( ) {
47+ const supabase = await createClient ( ) ;
48+ await supabase . auth . signOut ( ) ;
49+ revalidatePath ( '/' , 'layout' ) ;
50+ redirect ( '/auth/signin' ) ;
51+ }
0 commit comments