File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change 1
1
import { qrCode , recoveryCodes , secretKey } from '@/routes/two-factor' ;
2
- import { ref } from 'vue' ;
2
+ import { computed , ref } from 'vue' ;
3
3
4
4
const fetchJson = async < T > ( url : string ) : Promise < T > => {
5
5
const response = await fetch ( url , {
@@ -17,6 +17,8 @@ const qrCodeSvg = ref<string | null>(null);
17
17
const manualSetupKey = ref < string | null > ( null ) ;
18
18
const recoveryCodesList = ref < string [ ] > ( [ ] ) ;
19
19
20
+ const hasSetupData = computed < boolean > ( ( ) => qrCodeSvg . value !== null && manualSetupKey . value !== null ) ;
21
+
20
22
export const useTwoFactorAuth = ( ) => {
21
23
const fetchQrCode = async ( ) : Promise < void > => {
22
24
const { svg } = await fetchJson < { svg : string ; url : string } > ( qrCode . url ( ) ) ;
@@ -61,6 +63,7 @@ export const useTwoFactorAuth = () => {
61
63
qrCodeSvg,
62
64
manualSetupKey,
63
65
recoveryCodesList,
66
+ hasSetupData,
64
67
clearSetupData,
65
68
clearTwoFactorAuthData,
66
69
fetchQrCode,
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ const breadcrumbs: BreadcrumbItem[] = [
30
30
},
31
31
];
32
32
33
- const { clearTwoFactorAuthData } = useTwoFactorAuth ();
33
+ const { hasSetupData, clearTwoFactorAuthData } = useTwoFactorAuth ();
34
34
const showSetupModal = ref <boolean >(false );
35
35
36
36
onUnmounted (() => {
@@ -54,9 +54,10 @@ onUnmounted(() => {
54
54
</p >
55
55
56
56
<div >
57
- <Form v-bind =" enable.form()" @success =" showSetupModal = true" #default =" { processing }" >
58
- <Button type =" submit" :disabled =" processing" > <ShieldCheck />Enable 2FA</Button >
59
- </Form >
57
+ <Button v-if =" hasSetupData" @click =" showSetupModal = true" > <ShieldCheck />Continue Setup </Button >
58
+ <Form v-else v-bind =" enable.form()" @success =" showSetupModal = true" #default =" { processing }" >
59
+ <Button type =" submit" :disabled =" processing" > <ShieldCheck />Enable 2FA</Button ></Form
60
+ >
60
61
</div >
61
62
</div >
62
63
You can’t perform that action at this time.
0 commit comments