aboutsummaryrefslogtreecommitdiff
path: root/extension/src/entries/popup/Components/OtpLogin.vue
diff options
context:
space:
mode:
Diffstat (limited to 'extension/src/entries/popup/Components/OtpLogin.vue')
-rw-r--r--extension/src/entries/popup/Components/OtpLogin.vue51
1 files changed, 51 insertions, 0 deletions
diff --git a/extension/src/entries/popup/Components/OtpLogin.vue b/extension/src/entries/popup/Components/OtpLogin.vue
new file mode 100644
index 0000000..a2b8ac7
--- /dev/null
+++ b/extension/src/entries/popup/Components/OtpLogin.vue
@@ -0,0 +1,51 @@
+<template>
+ <form class="" @submit.prevent="onSubmit">
+ <fieldset class="px-4 input-container">
+ <label class="">Please enter your authentication token</label>
+ <textarea class="w-full input" v-model="token" rows="5" />
+ </fieldset>
+ <div class="flex justify-end mt-2">
+ <div class="px-3">
+ <button class="w-24 rounded btn sm primary">
+ <fa-icon v-if="waiting" icon="spinner" class="animate-spin" />
+ <span v-else>Submit</span>
+ </button>
+ </div>
+ </div>
+ </form>
+</template>
+
+<script setup lang="ts">
+import { apiCall, useWait } from "@vnuge/vnlib.browser";
+import { ref } from "vue";
+import { useStore } from "../../store";
+
+const { login } = useStore()
+const { waiting } = useWait()
+
+const token = ref('')
+
+const onSubmit = async () => {
+ await apiCall(async ({ toaster }) => {
+ try{
+ await login(token.value)
+
+ toaster.form.success({
+ 'title': 'Login successful',
+ 'text': 'Successfully logged into your profile'
+ })
+ }
+ catch(e:any){
+ if('response' in e){
+ throw e;
+ }
+
+ toaster.form.error({
+ title: 'Failed to login',
+ text: e.message
+ })
+ }
+ })
+}
+
+</script> \ No newline at end of file