Ran prettier. Moved Header to layout file
This commit is contained in:
@ -1,32 +1,33 @@
|
||||
'use server'
|
||||
'use server';
|
||||
|
||||
import 'server-only';
|
||||
import { revalidatePath } from 'next/cache'
|
||||
import { redirect } from 'next/navigation'
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
import { createClient } from '@/utils/supabase/server'
|
||||
import { createClient } from '@/utils/supabase/server';
|
||||
|
||||
export const login = async (formData: FormData) => {
|
||||
const supabase = await createClient()
|
||||
const supabase = await createClient();
|
||||
|
||||
// type-casting here for convenience
|
||||
// in practice, you should validate your inputs
|
||||
const data = {
|
||||
email: formData.get('email') as string,
|
||||
password: formData.get('password') as string,
|
||||
}
|
||||
};
|
||||
|
||||
const { error } = await supabase.auth.signInWithPassword(data)
|
||||
const { error } = await supabase.auth.signInWithPassword(data);
|
||||
|
||||
if (error) {
|
||||
redirect('/error')
|
||||
redirect('/error');
|
||||
}
|
||||
|
||||
revalidatePath('/', 'layout')
|
||||
revalidatePath('/', 'layout');
|
||||
redirect('/');
|
||||
};
|
||||
|
||||
export const signup = async (formData: FormData) => {
|
||||
const supabase = await createClient()
|
||||
const supabase = await createClient();
|
||||
|
||||
// type-casting here for convenience
|
||||
// in practice, you should validate your inputs
|
||||
@ -34,13 +35,14 @@ export const signup = async (formData: FormData) => {
|
||||
fullName: formData.get('fullName') as string,
|
||||
email: formData.get('email') as string,
|
||||
password: formData.get('password') as string,
|
||||
}
|
||||
};
|
||||
|
||||
const { error } = await supabase.auth.signUp(data)
|
||||
const { error } = await supabase.auth.signUp(data);
|
||||
|
||||
if (error) {
|
||||
redirect('/error')
|
||||
redirect('/error');
|
||||
}
|
||||
|
||||
revalidatePath('/', 'layout')
|
||||
revalidatePath('/', 'layout');
|
||||
redirect('/');
|
||||
};
|
||||
|
Reference in New Issue
Block a user