From 7c68628456d12a31a6d59b146df2ab614a86f5eb Mon Sep 17 00:00:00 2001 From: Clement Date: Sat, 20 Apr 2024 11:45:39 +0200 Subject: [PATCH] add register form test --- front/src/pages/account/register.astro | 44 ++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 front/src/pages/account/register.astro diff --git a/front/src/pages/account/register.astro b/front/src/pages/account/register.astro new file mode 100644 index 0000000..a73cb13 --- /dev/null +++ b/front/src/pages/account/register.astro @@ -0,0 +1,44 @@ +--- +import PocketBase from 'pocketbase'; +import Layout from '../../layouts/Layout.astro'; +import AstroUtils from '../../libs/AstroUtils'; + +//const connected = await getUser(Astro.cookies) + +// if(connected) { +// return Astro.redirect(route('/')) +// } + + +const res = await AstroUtils.wrap(async () => { + if (Astro.request.method !== 'POST'){ + return + } + const form = await Astro.request.formData() + const request = { + username: form.get("username") as String, + name: form.get("name") as String, + email: form.get("email") as String, + password: form.get("password") as String, + passwordConfirm: form.get("passwordConfirm") as String, + emailVisibility: false + } + const pb = new PocketBase('http://127.0.0.1:3001'); + + console.log(request); + const record = await pb.collection('users').create(request); + console.log(record); + +}) +--- + + +
+ + + + + + +
+
\ No newline at end of file