File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -34,19 +34,23 @@ export const useTwoFactorAuth = () => {
34
34
const fetchQrCode = useCallback ( async ( ) : Promise < void > => {
35
35
try {
36
36
const { svg } = await fetchJson < TwoFactorSetupData > ( qrCode . url ( ) ) ;
37
+
37
38
setQrCodeSvg ( svg ) ;
38
39
} catch ( error ) {
39
40
console . error ( 'Failed to fetch QR code:' , error ) ;
41
+
40
42
setQrCodeSvg ( null ) ;
41
43
}
42
44
} , [ ] ) ;
43
45
44
46
const fetchSetupKey = useCallback ( async ( ) : Promise < void > => {
45
47
try {
46
48
const { secretKey : key } = await fetchJson < TwoFactorSecretKey > ( secretKey . url ( ) ) ;
49
+
47
50
setManualSetupKey ( key ) ;
48
51
} catch ( error ) {
49
52
console . error ( 'Failed to fetch setup key:' , error ) ;
53
+
50
54
setManualSetupKey ( null ) ;
51
55
}
52
56
} , [ ] ) ;
@@ -59,9 +63,11 @@ export const useTwoFactorAuth = () => {
59
63
const fetchRecoveryCodes = useCallback ( async ( ) : Promise < void > => {
60
64
try {
61
65
const codes = await fetchJson < string [ ] > ( recoveryCodes . url ( ) ) ;
66
+
62
67
setRecoveryCodesList ( codes ) ;
63
68
} catch ( error ) {
64
69
console . error ( 'Failed to fetch recovery codes:' , error ) ;
70
+
65
71
setRecoveryCodesList ( [ ] ) ;
66
72
}
67
73
} , [ ] ) ;
@@ -71,6 +77,7 @@ export const useTwoFactorAuth = () => {
71
77
await Promise . all ( [ fetchQrCode ( ) , fetchSetupKey ( ) ] ) ;
72
78
} catch ( error ) {
73
79
console . error ( 'Failed to fetch setup data:' , error ) ;
80
+
74
81
setQrCodeSvg ( null ) ;
75
82
setManualSetupKey ( null ) ;
76
83
}
You can’t perform that action at this time.
0 commit comments