You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: adminforth/documentation/docs/tutorial/07-Plugins/02-TwoFactorsAuth.md
+232Lines changed: 232 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -207,6 +207,238 @@ plugins: [
207
207
...
208
208
```
209
209
210
+
## Request 2FA on custom Actions
211
+
212
+
You might want to to allow to call some custom critical/money related actions with additional 2FA approval. This eliminates risks caused by user cookies theft by some virous/doorway software after login.
213
+
214
+
To do it, first, create frontend custom component which wraps and intercepts click event to menu item, and in click handler do a call to `window.adminforthTwoFaModal.getCode(cb?)` frontend API exposed by this plugin. This is awaitable call wich shows 2FA popup and asks user to authenticate with 2nd factor (if passkey is enabled it will be suggested first, with ability to fallback to TOTP)
const verificationResult =awaitwindow.adminforthTwoFaModal.get2FaConfirmationResult(); // this will ask user to enter code
231
+
emit('callAction', { verificationResult }); // then we pass this verification result to action (from fronted to backend)
232
+
}
233
+
</script>
234
+
```
235
+
236
+
Now we need to use verification result which we got from user on frontend, inside of backend action handler and verify that it is valid (and not expired):
By default label prefix in Authenticator app is formed from Adminforth [brandName setting](/docs/tutorial/Customization/branding/) which is best behaviour for most admin apps (always remember to configure brandName correctly e.g. "RoyalFinTech Admin")
0 commit comments