mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
chore(mobile): refactor authentication (#14322)
This commit is contained in:
parent
5417e34fb6
commit
21f14be949
26 changed files with 619 additions and 354 deletions
69
mobile/lib/models/auth/auth_state.model.dart
Normal file
69
mobile/lib/models/auth/auth_state.model.dart
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
class AuthState {
|
||||
final String deviceId;
|
||||
final String userId;
|
||||
final String userEmail;
|
||||
final bool isAuthenticated;
|
||||
final String name;
|
||||
final bool isAdmin;
|
||||
final String profileImagePath;
|
||||
|
||||
AuthState({
|
||||
required this.deviceId,
|
||||
required this.userId,
|
||||
required this.userEmail,
|
||||
required this.isAuthenticated,
|
||||
required this.name,
|
||||
required this.isAdmin,
|
||||
required this.profileImagePath,
|
||||
});
|
||||
|
||||
AuthState copyWith({
|
||||
String? deviceId,
|
||||
String? userId,
|
||||
String? userEmail,
|
||||
bool? isAuthenticated,
|
||||
String? name,
|
||||
bool? isAdmin,
|
||||
String? profileImagePath,
|
||||
}) {
|
||||
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,
|
||||
profileImagePath: profileImagePath ?? this.profileImagePath,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
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 AuthState &&
|
||||
other.deviceId == deviceId &&
|
||||
other.userId == userId &&
|
||||
other.userEmail == userEmail &&
|
||||
other.isAuthenticated == isAuthenticated &&
|
||||
other.name == name &&
|
||||
other.isAdmin == isAdmin &&
|
||||
other.profileImagePath == profileImagePath;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return deviceId.hashCode ^
|
||||
userId.hashCode ^
|
||||
userEmail.hashCode ^
|
||||
isAuthenticated.hashCode ^
|
||||
name.hashCode ^
|
||||
isAdmin.hashCode ^
|
||||
profileImagePath.hashCode;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue