isUserMissingMfaAuth
Checks if the user requires additional MFA authentication. This function determines if the current user session requires additional multi-factor authentication to access certain features. This is typically used with session-based MFA to verify if a user needs to complete an MFA challenge. The function checks for the presence of therequiresAdditionalAuth scope in the user’s JWT token.
Usage
Parameters
| Parameter | Type | Description |
|---|---|---|
client | DynamicClient (optional) | The Dynamic client instance. Only required when using multiple clients. |
Returns
boolean - Returns true if the user needs additional MFA authentication, false otherwise.
Examples
Check and prompt for MFA
Protect sensitive actions
Conditional UI rendering
Listen for auth state changes
How it works
The function checks if the user’s JWT token contains therequiresAdditionalAuth scope:
- Session-based MFA is enabled and required
- The user has not yet completed an MFA challenge for the current session
- The user is required to set up MFA but hasn’t done so yet
Error handling
The function throws an error if the user is not logged in:Related
- isUserOnboardingComplete - Check if user completed all onboarding requirements
- isPendingRecoveryCodesAcknowledgment - Check if recovery codes need acknowledgment
- Session-Based MFA - Configure session-based MFA
- Action-Based MFA - Configure action-based MFA
- MFA Overview - Learn about MFA