From 082d4fc154f9db17bfc26c8362e6cf8cd8ca1304 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Thu, 29 Feb 2024 06:00:12 +0100 Subject: [PATCH] Added signup page. --- components/header/header.vue | 2 +- pages/auth/login/+Page.vue | 4 +- pages/auth/signup/+Page.vue | 236 +++++++++++++++++++++++ pages/auth/signup/+route.js | 1 + pages/users/@username/+Page.vue | 2 - pages/users/@username/+onBeforeRender.js | 6 + src/auth.js | 14 +- src/users.js | 12 +- src/web/auth.js | 2 - src/web/server.js | 24 +-- 10 files changed, 277 insertions(+), 26 deletions(-) create mode 100644 pages/auth/signup/+Page.vue create mode 100644 pages/auth/signup/+route.js diff --git a/components/header/header.vue b/components/header/header.vue index 505bdb8..1d87ebc 100644 --- a/components/header/header.vue +++ b/components/header/header.vue @@ -138,7 +138,7 @@ function search() { async function logout() { del('/session'); - window.location.reload(); + navigate('/login', null, { redirect: true }); } diff --git a/pages/auth/login/+Page.vue b/pages/auth/login/+Page.vue index 3915bee..53f2536 100644 --- a/pages/auth/login/+Page.vue +++ b/pages/auth/login/+Page.vue @@ -98,13 +98,13 @@ async function login() { errorMsg.value = null; try { - await post('/session', { + const loginUser = await post('/session', { username: username.value, password: password.value, redirect: pageContext.urlParsed.search.r, }); - navigate(decodeURIComponent(pageContext.urlParsed.search.r), null, { redirect: true }); + navigate(pageContext.urlParsed.search.r ? decodeURIComponent(pageContext.urlParsed.search.r) : `/user/${loginUser.username}`, null, { redirect: true }); } catch (error) { errorMsg.value = error.message; } diff --git a/pages/auth/signup/+Page.vue b/pages/auth/signup/+Page.vue new file mode 100644 index 0000000..b02fc80 --- /dev/null +++ b/pages/auth/signup/+Page.vue @@ -0,0 +1,236 @@ + + + + + diff --git a/pages/auth/signup/+route.js b/pages/auth/signup/+route.js new file mode 100644 index 0000000..001229a --- /dev/null +++ b/pages/auth/signup/+route.js @@ -0,0 +1 @@ +export default '/signup'; diff --git a/pages/users/@username/+Page.vue b/pages/users/@username/+Page.vue index c993ab3..2c99594 100644 --- a/pages/users/@username/+Page.vue +++ b/pages/users/@username/+Page.vue @@ -17,8 +17,6 @@ import { inject } from 'vue'; const pageContext = inject('pageContext'); const profile = pageContext.pageProps.profile; - -console.log('profile', profile);