Skip to main content
function isEnrolledInMfa(user: User, method?: MfaMethod): boolean;
Checks if the user is enrolled in MFA.

Parameters

ParameterTypeDescription
userUserThe user object.
method?MfaMethodOptional specific method to check. If not provided, checks if user has any MFA method enrolled.

Returns

boolean True if the user is enrolled in the specified method (or any method if not specified), false otherwise.

Example

const user = await getCurrentUser();

// Check if user has any MFA enrolled
if (isEnrolledInMfa(user)) {
  console.log("User has MFA enabled");
}

// Check if user has specific method enrolled
if (isEnrolledInMfa(user, "totp")) {
  console.log("User has TOTP MFA enabled");
}

if (isEnrolledInMfa(user, "sms")) {
  console.log("User has SMS MFA enabled");
}