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 {
|
class AuthUser {
|
||||||
final String id;
|
final String id;
|
||||||
final String email;
|
final String? email;
|
||||||
|
final String? phone;
|
||||||
final String name;
|
final String name;
|
||||||
final List<String> roles;
|
final List<String> roles;
|
||||||
final String? tenantId;
|
final String? tenantId;
|
||||||
|
|
||||||
const AuthUser({
|
const AuthUser({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.email,
|
this.email,
|
||||||
|
this.phone,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.roles,
|
required this.roles,
|
||||||
this.tenantId,
|
this.tenantId,
|
||||||
|
|
@ -36,7 +38,8 @@ class AuthUser {
|
||||||
factory AuthUser.fromJson(Map<String, dynamic> json) {
|
factory AuthUser.fromJson(Map<String, dynamic> json) {
|
||||||
return AuthUser(
|
return AuthUser(
|
||||||
id: json['id'] as String,
|
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,
|
name: json['name'] as String,
|
||||||
roles: (json['roles'] as List).cast<String>(),
|
roles: (json['roles'] as List).cast<String>(),
|
||||||
tenantId: json['tenantId'] as String?,
|
tenantId: json['tenantId'] as String?,
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ class AuthRepositoryImpl implements AuthRepository {
|
||||||
return AuthUserEntity(
|
return AuthUserEntity(
|
||||||
id: response.user.id,
|
id: response.user.id,
|
||||||
email: response.user.email,
|
email: response.user.email,
|
||||||
|
phone: response.user.phone,
|
||||||
name: response.user.name,
|
name: response.user.name,
|
||||||
roles: response.user.roles,
|
roles: response.user.roles,
|
||||||
);
|
);
|
||||||
|
|
@ -78,6 +79,7 @@ class AuthRepositoryImpl implements AuthRepository {
|
||||||
return AuthUserEntity(
|
return AuthUserEntity(
|
||||||
id: user.id,
|
id: user.id,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
|
phone: user.phone,
|
||||||
name: user.name,
|
name: user.name,
|
||||||
roles: user.roles,
|
roles: user.roles,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
/// Domain entity representing an authenticated user.
|
/// Domain entity representing an authenticated user.
|
||||||
class AuthUserEntity {
|
class AuthUserEntity {
|
||||||
final String id;
|
final String id;
|
||||||
final String email;
|
final String? email;
|
||||||
|
final String? phone;
|
||||||
final String name;
|
final String name;
|
||||||
final List<String> roles;
|
final List<String> roles;
|
||||||
final String? tenantId;
|
final String? tenantId;
|
||||||
|
|
@ -9,7 +10,8 @@ class AuthUserEntity {
|
||||||
|
|
||||||
const AuthUserEntity({
|
const AuthUserEntity({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.email,
|
this.email,
|
||||||
|
this.phone,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.roles,
|
required this.roles,
|
||||||
this.tenantId,
|
this.tenantId,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue