Skip to content

Commit cac41fb

Browse files
authored
fix(firebase_auth): Check if UserMetadata properties are null before parsing. (#8313)
1 parent 2504227 commit cac41fb

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

packages/firebase_auth/firebase_auth_web/lib/src/firebase_auth_web_user.dart

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ class UserWeb extends UserPlatform {
2525
'email': _webUser.email,
2626
'emailVerified': _webUser.emailVerified,
2727
'isAnonymous': _webUser.isAnonymous,
28-
'metadata': <String, int>{
29-
'creationTime': _dateFormat
30-
.parse(_webUser.metadata.creationTime)
31-
.millisecondsSinceEpoch,
32-
'lastSignInTime': _dateFormat
33-
.parse(_webUser.metadata.lastSignInTime)
34-
.millisecondsSinceEpoch,
28+
'metadata': <String, int?>{
29+
'creationTime': _webUser.metadata.creationTime != null
30+
? _dateFormat
31+
.parse(_webUser.metadata.creationTime!)
32+
.millisecondsSinceEpoch
33+
: null,
34+
'lastSignInTime': _webUser.metadata.lastSignInTime != null
35+
? _dateFormat
36+
.parse(_webUser.metadata.lastSignInTime!)
37+
.millisecondsSinceEpoch
38+
: null,
3539
},
3640
'phoneNumber': _webUser.phoneNumber,
3741
'photoURL': _webUser.photoURL,

packages/firebase_auth/firebase_auth_web/lib/src/interop/auth_interop.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,11 @@ abstract class ActionCodeInfo {
344344
abstract class UserMetadata {
345345
/// The date the user was created, formatted as a UTC string.
346346
/// For example, 'Fri, 22 Sep 2017 01:49:58 GMT'.
347-
external String get creationTime;
347+
external String? get creationTime;
348348

349349
/// The date the user last signed in, formatted as a UTC string.
350350
/// For example, 'Fri, 22 Sep 2017 01:49:58 GMT'.
351-
external String get lastSignInTime;
351+
external String? get lastSignInTime;
352352
}
353353

354354
/// A structure for [User]'s user profile.

0 commit comments

Comments
 (0)