chore(mobile): refactor authentication (#14322)

This commit is contained in:
Alex
2024-11-26 12:43:44 -06:00
committed by GitHub
parent 5417e34fb6
commit 21f14be949
26 changed files with 619 additions and 354 deletions
@@ -1,62 +1,58 @@
class AuthenticationState {
class AuthState {
final String deviceId;
final String userId;
final String userEmail;
final bool isAuthenticated;
final String name;
final bool isAdmin;
final bool shouldChangePassword;
final String profileImagePath;
AuthenticationState({
AuthState({
required this.deviceId,
required this.userId,
required this.userEmail,
required this.isAuthenticated,
required this.name,
required this.isAdmin,
required this.shouldChangePassword,
required this.profileImagePath,
});
AuthenticationState copyWith({
AuthState copyWith({
String? deviceId,
String? userId,
String? userEmail,
bool? isAuthenticated,
String? name,
bool? isAdmin,
bool? shouldChangePassword,
String? profileImagePath,
}) {
return AuthenticationState(
return AuthState(
deviceId: deviceId ?? this.deviceId,
userId: userId ?? this.userId,
userEmail: userEmail ?? this.userEmail,
isAuthenticated: isAuthenticated ?? this.isAuthenticated,
name: name ?? this.name,
isAdmin: isAdmin ?? this.isAdmin,
shouldChangePassword: shouldChangePassword ?? this.shouldChangePassword,
profileImagePath: profileImagePath ?? this.profileImagePath,
);
}
@override
String toString() {
return 'AuthenticationState(deviceId: $deviceId, userId: $userId, userEmail: $userEmail, isAuthenticated: $isAuthenticated, name: $name, isAdmin: $isAdmin, shouldChangePassword: $shouldChangePassword, profileImagePath: $profileImagePath)';
return 'AuthenticationState(deviceId: $deviceId, userId: $userId, userEmail: $userEmail, isAuthenticated: $isAuthenticated, name: $name, isAdmin: $isAdmin, profileImagePath: $profileImagePath)';
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is AuthenticationState &&
return other is AuthState &&
other.deviceId == deviceId &&
other.userId == userId &&
other.userEmail == userEmail &&
other.isAuthenticated == isAuthenticated &&
other.name == name &&
other.isAdmin == isAdmin &&
other.shouldChangePassword == shouldChangePassword &&
other.profileImagePath == profileImagePath;
}
@@ -68,7 +64,6 @@ class AuthenticationState {
isAuthenticated.hashCode ^
name.hashCode ^
isAdmin.hashCode ^
shouldChangePassword.hashCode ^
profileImagePath.hashCode;
}
}
@@ -0,0 +1,30 @@
class LoginResponse {
final String accessToken;
final bool isAdmin;
final String name;
final String profileImagePath;
final bool shouldChangePassword;
final String userEmail;
final String userId;
LoginResponse({
required this.accessToken,
required this.isAdmin,
required this.name,
required this.profileImagePath,
required this.shouldChangePassword,
required this.userEmail,
required this.userId,
});
@override
String toString() {
return 'LoginResponse[accessToken=$accessToken, isAdmin=$isAdmin, name=$name, profileImagePath=$profileImagePath, shouldChangePassword=$shouldChangePassword, userEmail=$userEmail, userId=$userId]';
}
}