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("/")