Skip to content

Commit 773b7de

Browse files
authored
fix: Support all mfa auth methods (#1030)
* fix: support all mfa auth methods * fix: add unknown mfa type * style: use orElse instead of firstWhereOrNull * style: remove import
1 parent 588b500 commit 773b7de

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

packages/gotrue/lib/src/types/mfa.dart

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,25 @@ class AuthMFAGetAuthenticatorAssuranceLevelResponse {
257257
});
258258
}
259259

260-
enum AMRMethod { password, otp, oauth, totp, magiclink }
260+
enum AMRMethod {
261+
password('password'),
262+
otp('otp'),
263+
oauth('oauth'),
264+
totp('totp'),
265+
magiclink('magiclink'),
266+
recovery('recovery'),
267+
invite('invite'),
268+
ssoSaml('sso/saml'),
269+
emailSignUp('email/signup'),
270+
emailChange('email_change'),
271+
tokenRefresh('token_refresh'),
272+
anonymous('anonymous'),
273+
mfaPhone('mfa/phone'),
274+
unknown('unknown');
275+
276+
final String code;
277+
const AMRMethod(this.code);
278+
}
261279

262280
/// An authentication method reference (AMR) entry.
263281
///
@@ -278,7 +296,8 @@ class AMREntry {
278296
factory AMREntry.fromJson(Map<String, dynamic> json) {
279297
return AMREntry(
280298
method: AMRMethod.values.firstWhere(
281-
(e) => e.name == json['method'],
299+
(e) => e.code == json['method'],
300+
orElse: () => AMRMethod.unknown,
282301
),
283302
timestamp: DateTime.fromMillisecondsSinceEpoch(json['timestamp'] * 1000),
284303
);

0 commit comments

Comments
 (0)