fix: update Dockerfile and remove .next from git
This commit is contained in:
45
app/login/actions.ts
Normal file
45
app/login/actions.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
'use server'
|
||||
|
||||
import { revalidatePath } from 'next/cache'
|
||||
import { redirect } from 'next/navigation'
|
||||
|
||||
import { createClient } from '@/utils/supabase/server'
|
||||
|
||||
export async function login(formData: FormData) {
|
||||
const supabase = await createClient()
|
||||
|
||||
const email = formData.get('email') as string
|
||||
const password = formData.get('password') as string
|
||||
|
||||
const { error } = await supabase.auth.signInWithPassword({
|
||||
email,
|
||||
password,
|
||||
})
|
||||
|
||||
if (error) {
|
||||
redirect('/login?error=Could not authenticate user')
|
||||
}
|
||||
|
||||
revalidatePath('/', 'layout')
|
||||
await supabase.rpc('reactivate_profile')
|
||||
redirect('/app')
|
||||
}
|
||||
|
||||
export async function signup(formData: FormData) {
|
||||
const supabase = await createClient()
|
||||
|
||||
const email = formData.get('email') as string
|
||||
const password = formData.get('password') as string
|
||||
|
||||
const { error } = await supabase.auth.signUp({
|
||||
email,
|
||||
password,
|
||||
})
|
||||
|
||||
if (error) {
|
||||
redirect('/login?error=Could not authenticate user')
|
||||
}
|
||||
|
||||
revalidatePath('/', 'layout')
|
||||
redirect('/app')
|
||||
}
|
||||
Reference in New Issue
Block a user