Skip to content

Commit 5e5aa93

Browse files
committed
dev-demo: add buttons to test 2fa frontend api
AdminForth/1304/plugins-frontend-api.-improve-
1 parent 5571213 commit 5e5aa93

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

dev-demo/custom/SystemTest.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
<Button @click="doTest2faCall">
2121
Test 2FA API Call
2222
</Button>
23+
24+
<Button @click="get2FaConfirmationResultWindow">
25+
2fa window.get2FaConfirmationResult (global window api)
26+
</Button>
27+
<Button @click="get2FaConfirmationResultTwoFactorsAuth">
28+
2fa twoFactorsAuth.get2FaConfirmationResult
29+
</Button>
2330
</div>
2431
</template>
2532

@@ -32,7 +39,9 @@ import { callApi } from '@/utils';
3239
3340
const { alert } = useAdminforth();
3441
import adminforth from '@/adminforth';
42+
import { useTwoFactorsAuth } from '@/custom/plugins/TwoFactorsAuthPlugin/use2faApi.ts';
3543
44+
const twoFactorsAuth = useTwoFactorsAuth();
3645
3746
const valueStart = ref()
3847
@@ -89,4 +98,14 @@ async function doTest2faCall() {
8998
console.error('2FA API error:', error);
9099
}
91100
}
101+
102+
async function get2FaConfirmationResultWindow() {
103+
const verificationResult = await window.adminforthTwoFaModal.get2FaConfirmationResult(); // this will ask user to enter code
104+
console.log('2FA verification result (window):', verificationResult);
105+
}
106+
107+
async function get2FaConfirmationResultTwoFactorsAuth() {
108+
const verificationResult = await twoFactorsAuth.get2FaConfirmationResult(); // this will ask user to enter code
109+
console.log('2FA verification result (twoFactorsAuth):', verificationResult);
110+
}
92111
</script>

0 commit comments

Comments
 (0)