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.
33 lines
603 B
Dart
33 lines
603 B
Dart
part of 'auth_bloc.dart';
|
|
|
|
abstract class AuthEvent extends Equatable {
|
|
const AuthEvent();
|
|
|
|
@override
|
|
List<Object> get props => [];
|
|
}
|
|
|
|
class AuthStarted extends AuthEvent {}
|
|
|
|
class AuthLoggedIn extends AuthEvent {
|
|
final User user;
|
|
|
|
const AuthLoggedIn({required this.user});
|
|
|
|
@override
|
|
List<Object> get props => [user];
|
|
}
|
|
|
|
class AuthLoggedOut extends AuthEvent {}
|
|
|
|
class AuthRegisterRequested extends AuthEvent {
|
|
final String name;
|
|
final String email;
|
|
|
|
const AuthRegisterRequested({required this.name, required this.email});
|
|
|
|
@override
|
|
List<Object> get props => [name, email];
|
|
}
|
|
|