update
This commit is contained in:
@@ -52,7 +52,19 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
AuthEventAddEmailAndPassword event, Emitter<AuthState> emit) async {
|
||||
emit(AuthStateProcess());
|
||||
try {
|
||||
await _userRepository.addEmailAndPassword(event.email, event.password);
|
||||
final String? error = await _userRepository.addEmailAndPassword(
|
||||
event.email, event.password);
|
||||
if (error == null) {
|
||||
emit(AuthStateSuccess());
|
||||
} else {
|
||||
if (error == 'requires-recent-login') {
|
||||
emit(AuthStateRequiresRecentLogin());
|
||||
} else if (error == 'email-already-in-use') {
|
||||
emit(AuthStateEmailAlreadyInUse());
|
||||
} else {
|
||||
emit(const AuthStateFailure());
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
emit(const AuthStateFailure());
|
||||
}
|
||||
|
||||
@@ -19,6 +19,10 @@ class AuthStateVerifyOAuth extends AuthState {
|
||||
|
||||
class AuthStateSuccess extends AuthState {}
|
||||
|
||||
class AuthStateRequiresRecentLogin extends AuthState {}
|
||||
|
||||
class AuthStateEmailAlreadyInUse extends AuthState {}
|
||||
|
||||
class AuthStateFailure extends AuthState {
|
||||
final String? message;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user