diff options
Diffstat (limited to 'front-end/src/views/Login/pki')
-rw-r--r-- | front-end/src/views/Login/pki/index.vue | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/front-end/src/views/Login/pki/index.vue b/front-end/src/views/Login/pki/index.vue index 585942a..8edd063 100644 --- a/front-end/src/views/Login/pki/index.vue +++ b/front-end/src/views/Login/pki/index.vue @@ -1,3 +1,38 @@ +<script setup lang="ts"> +import { isEmpty } from 'lodash-es'; +import { apiCall, debugLog, useMessage } from '@vnuge/vnlib.browser'; +import { ref } from 'vue' +import { decodeJwt } from 'jose' +import { useRouter } from 'vue-router'; +import { useStore } from '../../../store'; + +const { setMessage } = useMessage() +const { push } = useRouter() +const store = useStore() + +const otp = ref('') + +const submit = () => { + + apiCall(async () => { + if (isEmpty(otp.value)) { + setMessage('Please enter your OTP') + return + } + + //try to decode the jwt to confirm its form is valid + const jwt = decodeJwt(otp.value) + debugLog(jwt) + + await store.pki!.pkiAuth.login(otp.value) + + //Go back to login page + push({ name: 'Login' }) + }) +} + +</script> + <template> <div id="pki-login-template" class="app-component-entry"> <div class="container max-w-lg mx-auto mt-6 lg:mt-20"> @@ -30,38 +65,3 @@ </div> </div> </template> - -<script setup lang="ts"> -import { isEmpty } from 'lodash-es'; -import { apiCall, debugLog, useMessage } from '@vnuge/vnlib.browser'; -import { ref } from 'vue' -import { decodeJwt } from 'jose' -import { useRouter } from 'vue-router'; -import { useStore } from '../../../store'; - -const { setMessage } = useMessage() -const { push } = useRouter() -const store = useStore() - -const otp = ref('') - -const submit = () =>{ - - apiCall(async () =>{ - if(isEmpty(otp.value)){ - setMessage('Please enter your OTP') - return - } - - //try to decode the jwt to confirm its form is valid - const jwt = decodeJwt(otp.value) - debugLog(jwt) - - await store.pkiAuth.login(otp.value) - - //Go back to login page - push({ name: 'Login' }) - }) -} - -</script>
\ No newline at end of file |