@@ -227,8 +227,52 @@ plugins: [
227227
228228So such users will have suggestion to setup 2FA, but will be able to skip it with "Skip for now" button.
229229
230+ ## Calling 2FA modal from backend
231+ If you wan't to call 2FA verification modal from the backend for verification, you can use
230232
231- ## Step-Up MFA (Two-Factor re-authentication on critical operations)
233+ ` ` ` ts
234+ t2fa .verifyAuto (adminUser );
235+ ` ` `
236+ This method opens 2FA verification modal at the frontend and then returns verification result.
237+
238+ Here is an example:
239+
240+ ` ` ` ts title = " ./api.ts"
241+ // diff-add
242+ app .get (` ${admin .config .baseUrl }/api/test2faCall/ ` ,
243+ // diff-add
244+ admin .express .authorize (
245+ // diff-add
246+ async (_req : IAdminUserExpressRequest , res : Response ) => {
247+ // diff-add
248+ const { adminUser } = _req ;
249+ // diff-add
250+ // diff-add
251+ const t2fa = admin .getPluginByClassName (' TwoFactorsAuthPlugin' );
252+ // diff-add
253+ const verifyResult = await t2fa .verifyAuto (adminUser );
254+ // diff-add
255+ if (verifyResult .ok ) {
256+ // diff-add
257+ // some critical action
258+ // diff-add
259+ res .json ({ ok: " true" });
260+ // diff-add
261+ }
262+ // diff-add
263+ res .json ({ok: " false" , message: " Verification failed" })
264+ // diff-add
265+ }
266+ // diff-add
267+ )
268+ // diff-add
269+ );
270+ ` ` `
271+
272+ Under the hood, this metod uses websocket.
273+
274+ ## Manual Step-Up MFA (Two-Factor re-authentication on critical operations)
275+ But if you websocket doesn't work in you application, or you wan't to perform verification manually, here are manual verification examples
232276
233277### Request 2FA on custom Actions
234278
@@ -719,11 +763,12 @@ Now, update the settings of the Two-Factor Authentication plugin:
719763
720764 plugins : [
721765 new TwoFactorsAuthPlugin ({
722- keyValueAdapter: new RamKeyValueAdapter (),
723766 twoFaSecretFieldName: ' secret2fa' ,
724767 timeStepWindow: 1 ,
725768 // diff-add
726769 passkeys: {
770+ // diff-add
771+ keyValueAdapter: new RamKeyValueAdapter (),
727772 // diff-add
728773 credentialResourceID: " passkeys" ,
729774 // diff-add
0 commit comments