This commit is contained in:
@ -1,18 +1,16 @@
|
||||
---
|
||||
import PocketBase from 'pocketbase';
|
||||
import Layout from '../../layouts/Layout.astro';
|
||||
import AstroUtils from '../../libs/AstroUtils';
|
||||
import { getUser, setUser } from 'libs/AuthUtils';
|
||||
import type UserObj from 'models/User';
|
||||
import Layout from 'layouts/Layout.astro';
|
||||
import AstroUtils from 'libs/AstroUtils';
|
||||
import PocketBase from 'pocketbase'
|
||||
|
||||
const connected = await getUser(Astro.cookies)
|
||||
|
||||
if(connected) {
|
||||
return Astro.redirect(route('/'))
|
||||
const pb = Astro.locals.pb as PocketBase
|
||||
|
||||
if(pb.authStore.isValid){
|
||||
return Astro.redirect("/account")
|
||||
}
|
||||
|
||||
|
||||
const res = await AstroUtils.wrap(async () => {
|
||||
await AstroUtils.wrap(async () => {
|
||||
if (Astro.request.method !== 'POST'){
|
||||
return
|
||||
}
|
||||
@ -24,8 +22,12 @@ const res = await AstroUtils.wrap(async () => {
|
||||
password: form.get("password") as string,
|
||||
passwordConfirm: form.get("passwordConfirm") as string,
|
||||
}
|
||||
await setUser(Astro.cookies, request);
|
||||
|
||||
try{
|
||||
await pb.collection('users').create(request)
|
||||
return Astro.redirect('account/login')
|
||||
}catch(e){
|
||||
console.log(e);
|
||||
}
|
||||
})
|
||||
---
|
||||
|
||||
|
Reference in New Issue
Block a user