Enrolls a new factor.
FactorType.TOTP
or FactorType.Phone
as the factorType and use the returned id to create a challenge.mfa.createChallenge()
.mfa.verifyChallenge()
.mfa.createChallengeAndVerify()
.The type of MFA factor to enroll. Currently supports `FactorType.TOTP` and `FactorType.Phone`.
Domain which the user is enrolling with.
Factor type specific configuration.
val factor = supabase.auth.mfa.enroll(factorType = FactorType.TOTP, friendlyName = "Your friendly Name") \{
// Optional
issuer = "example.com"
\}
// Use the id to create a challenge.
// The challenge can be verified by entering the code generated from the authenticator app.
// The code will be generated upon scanning the qr_code or entering the secret into the authenticator app.
val (id, type, qrCode) = factor.data //qrCode is a svg as a string
val (factorId, factorType, _) = factor
val challenge = supabase.auth.mfa.createChallenge(factor.id)
val factor = supabase.auth.mfa.enroll(factorType = FactorType.Phone, friendlyName = "Your friendly Name") \{
phone = "+123456789"
\}
// Use the id to create a challenge and send an SMS with a code to the user.
val (phone) = factor.data
val (factorId, factorType, _) = factor
val challenge = supabase.auth.mfa.createChallenge(factor.id)
val verifiedFactors = supabase.auth.mfa.verifiedFactors
val verifiedFactors = supabase.auth.mfa.retrieveFactorsForCurrentUser()