Skip to content

Commit 15c3f53

Browse files
committed
fix: add unknown mfa type
1 parent 0e5569c commit 15c3f53

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:collection/collection.dart';
12
import 'package:gotrue/gotrue.dart';
23

34
class AuthMFAEnrollResponse {
@@ -270,7 +271,8 @@ enum AMRMethod {
270271
emailChange('email_change'),
271272
tokenRefresh('token_refresh'),
272273
anonymous('anonymous'),
273-
mfaPhone('mfa/phone');
274+
mfaPhone('mfa/phone'),
275+
unknown('unknown');
274276

275277
final String code;
276278
const AMRMethod(this.code);
@@ -294,9 +296,10 @@ class AMREntry {
294296

295297
factory AMREntry.fromJson(Map<String, dynamic> json) {
296298
return AMREntry(
297-
method: AMRMethod.values.firstWhere(
298-
(e) => e.code == json['method'],
299-
),
299+
method: AMRMethod.values.firstWhereOrNull(
300+
(e) => e.code == json['method'],
301+
) ??
302+
AMRMethod.unknown,
300303
timestamp: DateTime.fromMillisecondsSinceEpoch(json['timestamp'] * 1000),
301304
);
302305
}

0 commit comments

Comments
 (0)