Working nice, still looking kinda shit
This commit is contained in:
41
src/routes/auth/signup/+page.server.ts
Normal file
41
src/routes/auth/signup/+page.server.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { redirect } from '@sveltejs/kit'
|
||||
|
||||
import type { Actions } from './$types'
|
||||
|
||||
export const actions: Actions = {
|
||||
signup: async ({ request, locals: { supabase } }) => {
|
||||
const formData = await request.formData()
|
||||
const email = formData.get('email') as string
|
||||
const password = formData.get('password') as string
|
||||
const display_name = formData.get('display_name') as string
|
||||
|
||||
const { error } = await supabase.auth.signUp({
|
||||
email,
|
||||
password,
|
||||
options: {
|
||||
data: {
|
||||
display_name: display_name
|
||||
}
|
||||
}
|
||||
});
|
||||
if (error) {
|
||||
console.error(error)
|
||||
redirect(303, '/auth/error')
|
||||
} else {
|
||||
redirect(303, '/')
|
||||
}
|
||||
},
|
||||
login: async ({ request, locals: { supabase } }) => {
|
||||
const formData = await request.formData()
|
||||
const email = formData.get('email') as string
|
||||
const password = formData.get('password') as string
|
||||
|
||||
const { error } = await supabase.auth.signInWithPassword({ email, password })
|
||||
if (error) {
|
||||
console.error(error)
|
||||
redirect(303, '/auth/error')
|
||||
} else {
|
||||
redirect(303, '/private/home')
|
||||
}
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user