Skip to content

Commit

Permalink
fix: support all mfa auth methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinzent03 committed Sep 10, 2024
1 parent a12b097 commit 0e5569c
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions packages/gotrue/lib/src/types/mfa.dart
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,24 @@ class AuthMFAGetAuthenticatorAssuranceLevelResponse {
});
}

enum AMRMethod { password, otp, oauth, totp, magiclink }
enum AMRMethod {
password('password'),
otp('otp'),
oauth('oauth'),
totp('totp'),
magiclink('magiclink'),
recovery('recovery'),
invite('invite'),
ssoSaml('sso/saml'),
emailSignUp('email/signup'),
emailChange('email_change'),
tokenRefresh('token_refresh'),
anonymous('anonymous'),
mfaPhone('mfa/phone');

final String code;
const AMRMethod(this.code);
}

/// An authentication method reference (AMR) entry.
///
Expand All @@ -278,7 +295,7 @@ class AMREntry {
factory AMREntry.fromJson(Map<String, dynamic> json) {
return AMREntry(
method: AMRMethod.values.firstWhere(
(e) => e.name == json['method'],
(e) => e.code == json['method'],
),
timestamp: DateTime.fromMillisecondsSinceEpoch(json['timestamp'] * 1000),
);
Expand Down

0 comments on commit 0e5569c

Please sign in to comment.