Compare commits

...

3 Commits

Author SHA1 Message Date
5a49f5beda rm some log 2024-04-20 12:09:05 +02:00
70382d7bd8 feat: login page test 2024-04-20 12:08:49 +02:00
a724c1270f fix: change register form name 2024-04-20 12:07:37 +02:00
2 changed files with 46 additions and 2 deletions

View File

@ -0,0 +1,44 @@
---
import Layout from "../../layouts/Layout.astro";
import PocketBase from 'pocketbase';
import AstroUtils from "../../libs/AstroUtils";
import Schema from 'models/Schema'
// const usr = await getUser(Astro.cookies)
// if (usr) {
// return Astro.redirect(route('/', {message: 'Vous êtes déjà connecté !'}))
// }
const res = await AstroUtils.wrap(async () => {
if (Astro.request.method !== 'POST') {
return
}
const form = await Astro.request.formData();
const request = {
email: form.get("username") as String,
password: form.get("password") as String
}
const pb = new PocketBase('http://127.0.0.1:3001');
const authData = await pb.collection('users').authWithPassword(
request.email,
request.password,
);
// after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
})
---
<Layout title="login">
<form id="account-creation" method="post" enctype="multipart/form-data">
<input required name="username" placeholder="Pseudo ou email"/>
<input required name="password" type="password" placeholder="Mot de passe" />
<button>Connection</button>
</form>
</Layout>

View File

@ -34,8 +34,8 @@ const res = await AstroUtils.wrap(async () => {
<Layout title="register"> <Layout title="register">
<form id="account-creation" method="post" enctype="multipart/form-data"> <form id="account-creation" method="post" enctype="multipart/form-data">
<input required name="name" placeholder="Nom"/> <input required name="name" placeholder="Prénom Nom"/>
<input required name="username" placeholder="Prénom"/> <input required name="username" placeholder="Pseudo"/>
<input required name="email" type="email" placeholder="Renseignez votre email" /> <input required name="email" type="email" placeholder="Renseignez votre email" />
<input required name="password" type="password" placeholder="Créez un mot de passe" /> <input required name="password" type="password" placeholder="Créez un mot de passe" />
<input required name="passwordConfirm" type="password" placeholder="Confirmer votre mot de passe" /> <input required name="passwordConfirm" type="password" placeholder="Confirmer votre mot de passe" />