fix(app): make AuthUser.email nullable, add phone field
Phone-invited users have null email — casting null to String crashed login. email: String → String?, added phone: String? to AuthUser and AuthUserEntity. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
1cf502ef91
commit
4b2b3dca0c
|
|
@ -20,14 +20,16 @@ class AuthResponse {
|
|||
|
||||
class AuthUser {
|
||||
final String id;
|
||||
final String email;
|
||||
final String? email;
|
||||
final String? phone;
|
||||
final String name;
|
||||
final List<String> roles;
|
||||
final String? tenantId;
|
||||
|
||||
const AuthUser({
|
||||
required this.id,
|
||||
required this.email,
|
||||
this.email,
|
||||
this.phone,
|
||||
required this.name,
|
||||
required this.roles,
|
||||
this.tenantId,
|
||||
|
|
@ -36,7 +38,8 @@ class AuthUser {
|
|||
factory AuthUser.fromJson(Map<String, dynamic> json) {
|
||||
return AuthUser(
|
||||
id: json['id'] as String,
|
||||
email: json['email'] as String,
|
||||
email: json['email'] as String?,
|
||||
phone: json['phone'] as String?,
|
||||
name: json['name'] as String,
|
||||
roles: (json['roles'] as List).cast<String>(),
|
||||
tenantId: json['tenantId'] as String?,
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ class AuthRepositoryImpl implements AuthRepository {
|
|||
return AuthUserEntity(
|
||||
id: response.user.id,
|
||||
email: response.user.email,
|
||||
phone: response.user.phone,
|
||||
name: response.user.name,
|
||||
roles: response.user.roles,
|
||||
);
|
||||
|
|
@ -78,6 +79,7 @@ class AuthRepositoryImpl implements AuthRepository {
|
|||
return AuthUserEntity(
|
||||
id: user.id,
|
||||
email: user.email,
|
||||
phone: user.phone,
|
||||
name: user.name,
|
||||
roles: user.roles,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
/// Domain entity representing an authenticated user.
|
||||
class AuthUserEntity {
|
||||
final String id;
|
||||
final String email;
|
||||
final String? email;
|
||||
final String? phone;
|
||||
final String name;
|
||||
final List<String> roles;
|
||||
final String? tenantId;
|
||||
|
|
@ -9,7 +10,8 @@ class AuthUserEntity {
|
|||
|
||||
const AuthUserEntity({
|
||||
required this.id,
|
||||
required this.email,
|
||||
this.email,
|
||||
this.phone,
|
||||
required this.name,
|
||||
required this.roles,
|
||||
this.tenantId,
|
||||
|
|
|
|||
Loading…
Reference in New Issue