diff --git a/Makefile b/Makefile index f97671d..bc6334b 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,6 @@ client/dist/index.html: build-client: client/dist/index.html start-server: build-client - -mkdir db.mount docker compose up --build -d clean: diff --git a/client/src/components/NavBar.vue b/client/src/components/NavBar.vue index 9b3699d..64a6d6e 100644 --- a/client/src/components/NavBar.vue +++ b/client/src/components/NavBar.vue @@ -2,12 +2,11 @@ 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') - state.user = undefined + console.debug('logged out') router.push('/login') } diff --git a/client/src/views/Login.vue b/client/src/views/Login.vue index 84d09b7..a50bf9d 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, password = $password.value + const $name = name.value signUpWait.value = true const result = await fetch("/api/v1/auth", { method: 'POST', - body: JSON.stringify({ name, password }), + body: JSON.stringify({ name: $name, password: password.value }), headers: {'Content-Type': 'application/json'} }) if (result.ok) { - state.user = { name } + state.user = { name: $name } await state.repopulate() router.push("/") } } async function login() { - const name = $name.value, password = $password.value + const $name = name.value loginWait.value = true const result = await fetch("/api/v1/auth", { method: 'PUT', - body: JSON.stringify({ name, password }), + body: JSON.stringify({ name: $name, password: password.value }), headers: {'Content-Type': 'application/json'} }) if (result.ok) { - state.user = { name } + state.user = { name: $name } await state.repopulate() router.push("/") } @@ -54,14 +54,14 @@ if(state.user?.name) router.push("/")