From db3ef7640a9524ca2cff23b83ed5b7aab5881534 Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Sat, 26 Aug 2023 06:41:27 -0400 Subject: [PATCH 01/10] Renamed a variable sorry it was bothering me. --- client/src/views/Login.vue | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/client/src/views/Login.vue b/client/src/views/Login.vue index a50bf9d..84d09b7 100644 --- a/client/src/views/Login.vue +++ b/client/src/views/Login.vue @@ -3,38 +3,38 @@ import { ref, computed } from 'vue' import { state } from '../state'; import router from '../router' -const name = ref("") -const password = ref("") +const $name = ref("") +const $password = ref("") const signUpWait = ref(false) const loginWait = ref(false) const signUpClass = computed(() => `submit button is-success ${signUpWait.value ? 'is-loading' : ''}`) const loginClass = computed(() => `submit button is-info ${loginWait.value ? 'is-loading' : ''}`) async function signUp() { - const $name = name.value + const name = $name.value, password = $password.value signUpWait.value = true const result = await fetch("/api/v1/auth", { method: 'POST', - body: JSON.stringify({ name: $name, password: password.value }), + body: JSON.stringify({ name, password }), headers: {'Content-Type': 'application/json'} }) if (result.ok) { - state.user = { name: $name } + state.user = { name } await state.repopulate() router.push("/") } } async function login() { - const $name = name.value + const name = $name.value, password = $password.value loginWait.value = true const result = await fetch("/api/v1/auth", { method: 'PUT', - body: JSON.stringify({ name: $name, password: password.value }), + body: JSON.stringify({ name, password }), headers: {'Content-Type': 'application/json'} }) if (result.ok) { - state.user = { name: $name } + state.user = { name } await state.repopulate() router.push("/") } @@ -54,14 +54,14 @@ if(state.user?.name) router.push("/")
- +
- +
From 5aa16762f7104bdbdc251d3c102381a5a7120870 Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Sat, 26 Aug 2023 06:44:17 -0400 Subject: [PATCH 02/10] Quick tweak --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index bc6334b..f97671d 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ client/dist/index.html: build-client: client/dist/index.html start-server: build-client + -mkdir db.mount docker compose up --build -d clean: From 003383e45565b5463fa73c48e7897aec2ecb0c70 Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Sat, 26 Aug 2023 06:54:42 -0400 Subject: [PATCH 03/10] Fixed logout flow --- client/src/components/NavBar.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/components/NavBar.vue b/client/src/components/NavBar.vue index 64a6d6e..9b3699d 100644 --- a/client/src/components/NavBar.vue +++ b/client/src/components/NavBar.vue @@ -2,11 +2,12 @@ import { RouterLink } from 'vue-router'; import { error } from '../error' import router from "../router"; +import { state } from '../state' async function logOut() { const result = await fetch('/api/v1/auth', {method: 'DELETE'}) if(!result.ok) return error('failed to log out') - console.debug('logged out') + state.user = undefined router.push('/login') } From dafdd491f959741709e05795594ca70ef863c387 Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Sat, 26 Aug 2023 07:03:16 -0400 Subject: [PATCH 04/10] Move logOut function into method on state --- client/src/components/NavBar.vue | 9 +-------- client/src/state.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/client/src/components/NavBar.vue b/client/src/components/NavBar.vue index 9b3699d..9a09c57 100644 --- a/client/src/components/NavBar.vue +++ b/client/src/components/NavBar.vue @@ -1,15 +1,8 @@