diff options
Diffstat (limited to 'src/views/LogIn.vue')
-rw-r--r-- | src/views/LogIn.vue | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/views/LogIn.vue b/src/views/LogIn.vue index fb9bdcd..77999f2 100644 --- a/src/views/LogIn.vue +++ b/src/views/LogIn.vue @@ -1,7 +1,7 @@ <script setup lang="ts"> -import { ref, toRaw } from "vue" +import { ref, toRaw } from 'vue' import { RouterLink, useRouter } from 'vue-router' -import axios from "axios" +import axios from 'axios' import { useToast } from 'vue-toast-notification' const toast = useToast({ @@ -11,8 +11,8 @@ const toast = useToast({ const router = useRouter() const isLoading = ref(false) -const email = ref("") -const password = ref("") +const email = ref('') +const password = ref('') const login = async (e) => { e.preventDefault() @@ -20,25 +20,25 @@ const login = async (e) => { try { const res = await axios.post('/auth/signin', { - "accountname": toRaw(email.value), - "password": toRaw(password.value), - "method": "email" + accountname: toRaw(email.value), + password: toRaw(password.value), + method: 'email' }) - localStorage.setItem("authToken", res.data.auth_token) - localStorage.setItem("refToken", res.data.refresh_token) + localStorage.setItem('authToken', res.data.auth_token) + localStorage.setItem('refToken', res.data.refresh_token) toast.default(`Welcome, ${res.data.data.Username}`) - router.push({ path: "/" }) + router.push({ path: '/' }) } catch (err) { const statusCode = err.request.status - switch(statusCode) { + switch (statusCode) { case 401: toast.error('Password is incorrect') - break; + break case 404: toast.error('User does not exist') - break; + break default: toast.error('An unhandled exception occoured. Please check logs') } @@ -116,7 +116,11 @@ const login = async (e) => { </div> --> - <button type="submit" class="btn btn-primary btn-block mb-4" :class="{ disabled: isLoading }"> + <button + type="submit" + class="btn btn-primary btn-block mb-4" + :class="{ disabled: isLoading }" + > Sign In <div v-if="isLoading" class="spinner-border spinner-border-sm ms-1" role="status"> <span class="sr-only"></span> |