Skip to content

Commit

Permalink
chore: add missing emailVerified, phoneNumber and `phoneNumberVer…
Browse files Browse the repository at this point in the history
…ified` fields (#140)

* chore: add missing `emailVerified`, `phoneNumber` and `phoneNumberVerified` fields

* fix: test: add required parameter

* style: fix: `non_nullable_equals_parameter` lint

* fix: handle null phoneNumber in User fromJson

---------

Co-authored-by: Hassan Ben Jobrane <[email protected]>
  • Loading branch information
totzk9 and onehassan authored Jul 19, 2024
1 parent 20b8d53 commit adc184e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/nhost_dart/test/test_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ User createTestUser({required String id, required String email}) {
roles: ['user'],
isAnonymous: false,
metadata: {'age': 14, 'height': 162},
emailVerified: true,
phoneNumber: defaultTestPhone,
phoneNumberVerified: true,
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/nhost_flutter_auth/lib/src/provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class AuthNotifier extends ChangeNotifier
int get hashCode => value.hashCode;

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
if (identical(this, other)) return true;
if (other.runtimeType != runtimeType) return false;
return other is AuthNotifier && other.value == value;
Expand Down
15 changes: 15 additions & 0 deletions packages/nhost_sdk/lib/src/api/auth_api_types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ class User {
required this.isAnonymous,
required this.defaultRole,
required this.roles,
required this.emailVerified,
required this.phoneNumber,
required this.phoneNumberVerified,
this.metadata,
this.email,
this.avatarUrl,
Expand All @@ -113,6 +116,9 @@ class User {
final String defaultRole;
final List<String> roles;
final Map<String, Object?>? metadata;
final bool emailVerified;
final String phoneNumber;
final bool phoneNumberVerified;

static User fromJson(dynamic json) {
return User(
Expand All @@ -130,6 +136,9 @@ class User {
metadata: json['metadata'] == null
? null
: <String, Object?>{...json['metadata']},
emailVerified: json['emailVerified'] as bool,
phoneNumber: json['phoneNumber'] ?? '',
phoneNumberVerified: json['phoneNumberVerified'] as bool,
);
}

Expand All @@ -145,6 +154,9 @@ class User {
'defaultRole': defaultRole,
'metadata': metadata,
'roles': roles,
'emailVerified': emailVerified,
'phoneNumber': phoneNumber,
'phoneNumberVerified': phoneNumberVerified,
};
}

Expand All @@ -161,6 +173,9 @@ class User {
'metadata': metadata,
'email': email,
'avatarUrl': avatarUrl,
'emailVerified': emailVerified,
'phoneNumber': phoneNumber,
'phoneNumberVerified': phoneNumberVerified,
}.toString();
}
}
Expand Down

0 comments on commit adc184e

Please sign in to comment.