From 5f642a6aa0f16ad30d7815438ece311d165ab264 Mon Sep 17 00:00:00 2001 From: Clement Date: Fri, 26 Apr 2024 16:25:04 +0200 Subject: [PATCH] feat/ login on est pas mal --- front/src/pages/account/index.astro | 3 +++ front/src/pages/account/login.astro | 6 ++---- front/src/pages/account/logout.astro | 13 +++++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 front/src/pages/account/logout.astro diff --git a/front/src/pages/account/index.astro b/front/src/pages/account/index.astro index fbb2ced..39a434b 100644 --- a/front/src/pages/account/index.astro +++ b/front/src/pages/account/index.astro @@ -15,4 +15,7 @@ if(!auth.isValid){

Bonjour {user!.name}

+
+ deconnexion +
diff --git a/front/src/pages/account/login.astro b/front/src/pages/account/login.astro index 9ad54b0..6f3cd39 100644 --- a/front/src/pages/account/login.astro +++ b/front/src/pages/account/login.astro @@ -24,13 +24,11 @@ const res = await AstroUtils.wrap(async () => { } try { - await locals.pb.collection('users').authWithPassword(request.user,request.password); + pb.collection('users').authWithPassword(request.user,request.password); + return Astro.redirect("/account") } catch (error) { console.log(error) } - - return Astro.redirect("/account") - }) --- diff --git a/front/src/pages/account/logout.astro b/front/src/pages/account/logout.astro new file mode 100644 index 0000000..28472f1 --- /dev/null +++ b/front/src/pages/account/logout.astro @@ -0,0 +1,13 @@ +--- +import PocketBase from 'pocketbase' + + +const pb = Astro.locals.pb as PocketBase + +if(pb.authStore.isValid){ + pb.authStore.clear() +} + +return Astro.redirect('/account/login') + +--- \ No newline at end of file