From 70382d7bd853a7011b1a5607da365b71a6b4dedc Mon Sep 17 00:00:00 2001 From: Clement Date: Sat, 20 Apr 2024 12:08:49 +0200 Subject: [PATCH] feat: login page test --- front/src/pages/account/login.astro | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 front/src/pages/account/login.astro diff --git a/front/src/pages/account/login.astro b/front/src/pages/account/login.astro new file mode 100644 index 0000000..a597d49 --- /dev/null +++ b/front/src/pages/account/login.astro @@ -0,0 +1,46 @@ +--- +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, + ); + + console.log(authData) + + // 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); + +}) +--- + + +
+ + + +
+
\ No newline at end of file