File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
packages/gotrue/lib/src/types Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ class AuthMFAEnrollResponse {
2929 ? TOTPEnrollment .fromJson (json['totp' ])
3030 : null ,
3131 phone: type == FactorType .phone && json['phone' ] != null
32- ? PhoneEnrollment .fromJson (json['phone' ])
32+ ? PhoneEnrollment ._fromJsonValue (json['phone' ])
3333 : null ,
3434 );
3535 }
@@ -77,6 +77,19 @@ class PhoneEnrollment {
7777 phone: json['phone' ],
7878 );
7979 }
80+
81+ factory PhoneEnrollment ._fromJsonValue (dynamic value) {
82+ if (value is String ) {
83+ // Server returns phone number as a string directly
84+ return PhoneEnrollment (phone: value);
85+ } else if (value is Map <String , dynamic >) {
86+ // Server returns phone data as an object
87+ return PhoneEnrollment .fromJson (value);
88+ } else {
89+ throw ArgumentError (
90+ 'Invalid phone enrollment data type: ${value .runtimeType }' );
91+ }
92+ }
8093}
8194
8295class AuthMFAChallengeResponse {
You can’t perform that action at this time.
0 commit comments