aboutsummaryrefslogtreecommitdiff
path: root/front-end/src/views/Login/index.vue
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2023-08-27 22:28:34 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2023-08-27 22:28:34 -0400
commitafdeeb686f3aa022bec19084a337e233c622b4e3 (patch)
treef781d4b60e149244e58b58b44715a9a83c9d1fc1 /front-end/src/views/Login/index.vue
parent51a65e9196f35393817ba94721503afdfa76fb60 (diff)
pre backend update client performance bufs and fixes
Diffstat (limited to 'front-end/src/views/Login/index.vue')
-rw-r--r--front-end/src/views/Login/index.vue41
1 files changed, 22 insertions, 19 deletions
diff --git a/front-end/src/views/Login/index.vue b/front-end/src/views/Login/index.vue
index 7c30047..fea02d4 100644
--- a/front-end/src/views/Login/index.vue
+++ b/front-end/src/views/Login/index.vue
@@ -52,7 +52,7 @@ import {
useMfaLogin, totpMfaProcessor, IMfaFlowContinuiation, MfaMethod, apiCall,
useMessage, useWait, useUser, useSession, useLastPage, useTitle, debugLog
} from '@vnuge/vnlib.browser'
-import { useTimeoutFn } from '@vueuse/shared'
+import { useTimeoutFn } from '@vueuse/core'
import { isNil } from 'lodash-es'
useTitle('Login')
@@ -74,7 +74,13 @@ const { gotoLastPage } = useLastPage()
useTimeoutFn(() => loggedIn.value ? gotoLastPage() : null, 500)
const mfaUpgrade = ref<IMfaFlowContinuiation>();
-const mfaTimer = ref<{stop:() => void}>();
+const mfaTimeout = ref<number>(600 * 1000);
+const { start, stop } = useTimeoutFn(() => {
+ //Clear upgrade message
+ mfaUpgrade.value = undefined;
+ setMessage('Your TOTP request has expired')
+}, mfaTimeout, { immediate: false })
+
const showTotp = computed(() => mfaUpgrade.value?.type === MfaMethod.TOTP)
const submitLogout = async () => {
@@ -96,9 +102,14 @@ const submitLogin = async ({username, password} : { username: string, password:s
// Run login in an apicall wrapper
await apiCall(async ({ toaster }) => {
// Attempt to login
- const response = await login(username, password)
+ const response = await login(username, password);
- debugLog('Mfa-login',response)
+ debugLog('Mfa-login', response)
+
+ if(response.success == false){
+ setMessage(response.result)
+ return;
+ }
//Try to get response as a flow continuation
const mfa = response as IMfaFlowContinuiation
@@ -108,16 +119,9 @@ const submitLogin = async ({username, password} : { username: string, password:s
//Store the upgrade message
mfaUpgrade.value = mfa;
-
- // Set timeout to reset the form when totp expires
- mfaTimer.value = useTimeoutFn(() => {
-
- //Clear upgrade message
- mfaUpgrade.value = undefined;
-
- setMessage('Your TOTP request has expired')
-
- }, mfa.expires! * 1000)
+ //Setup timeout timer
+ mfaTimeout.value = mfa.expires! * 1000;
+ start();
}
//If login without mfa was successful
else if (response.success) {
@@ -126,8 +130,6 @@ const submitLogin = async ({username, password} : { username: string, password:s
title: 'Success',
text: 'You have been logged in',
})
-
- return;
}
})
}
@@ -135,15 +137,16 @@ const submitLogin = async ({username, password} : { username: string, password:s
const totpSubmit = ({ code } : {code:number}) =>{
apiCall(async ({ toaster }) =>{
- if (!mfaUpgrade.value)
+ if (!mfaUpgrade.value){
return;
+ }
//Submit totp code
const res = await mfaUpgrade.value.submit({ code })
res.getResultOrThrow()
- //Clear timer
- mfaTimer.value?.stop()
+ //Clear timer
+ stop();
//Clear upgrade message
mfaUpgrade.value = undefined;