login okay
Some checks failed
Build Docker Image / run (push) Failing after 30s

This commit is contained in:
2024-04-26 16:00:53 +02:00
parent 06bdeff188
commit 02e84ed9d6
3 changed files with 35 additions and 27 deletions

View File

@ -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);
}
})
---