This commit implements a complete authentication flow, including user registration. - Introduces an `AuthRegisterRequested` event to handle user registration. - Persists the user ID in settings upon successful authentication. - Modifies `AuthBloc` to load the user based on the stored ID, improving app launch persistence. - Refactors `UserCubit` to only manage the user state and removes authentication logic. - Removes `UserCubit` initialization from `main.dart` and triggers `AuthStarted` to initiate the authentication process.
34 lines
583 B
Dart
34 lines
583 B
Dart
part of 'auth_bloc.dart';
|
|
|
|
abstract class AuthState extends Equatable {
|
|
const AuthState();
|
|
|
|
@override
|
|
List<Object> get props => [];
|
|
}
|
|
|
|
class AuthInitial extends AuthState {}
|
|
|
|
class AuthLoading extends AuthState {}
|
|
|
|
class AuthAuthenticated extends AuthState {
|
|
final User user;
|
|
|
|
const AuthAuthenticated({required this.user});
|
|
|
|
@override
|
|
List<Object> get props => [user];
|
|
}
|
|
|
|
class AuthUnauthenticated extends AuthState {}
|
|
|
|
class AuthError extends AuthState {
|
|
final String message;
|
|
|
|
const AuthError(this.message);
|
|
|
|
@override
|
|
List<Object> get props => [message];
|
|
}
|
|
|