refactor: make signup/in, passwordreset cubit extendable
This commit is contained in:
		
							parent
							
								
									2088e0e4bc
								
							
						
					
					
						commit
						e6c234f0ea
					
				| @ -91,6 +91,17 @@ class AuthenticationRepositoryImpl<T extends Object> | |||||||
|           ], |           ], | ||||||
|           name: AuthFormName.signUpForm, |           name: AuthFormName.signUpForm, | ||||||
|         ), |         ), | ||||||
|  |       ) | ||||||
|  |       ..registerForm( | ||||||
|  |         WyattFormImpl( | ||||||
|  |           [ | ||||||
|  |             FormInput( | ||||||
|  |               AuthFormField.email, | ||||||
|  |               customEmailValidator ?? const Email.pure(), | ||||||
|  |             ), | ||||||
|  |           ], | ||||||
|  |           name: AuthFormName.passwordResetForm, | ||||||
|  |         ), | ||||||
|       ); |       ); | ||||||
|   } |   } | ||||||
|   final AuthenticationCacheDataSource<T> _authenticationLocalDataSource; |   final AuthenticationCacheDataSource<T> _authenticationLocalDataSource; | ||||||
|  | |||||||
| @ -27,27 +27,26 @@ part 'authentication_state.dart'; | |||||||
| 
 | 
 | ||||||
| class AuthenticationCubit<Extra> extends Cubit<AuthenticationState<Extra>> { | class AuthenticationCubit<Extra> extends Cubit<AuthenticationState<Extra>> { | ||||||
|   AuthenticationCubit({ |   AuthenticationCubit({ | ||||||
|     required AuthenticationRepository<Extra> authenticationRepository, |     required this.authenticationRepository, | ||||||
|   })  : _authenticationRepository = authenticationRepository, |   }) : super(const AuthenticationState.unknown()) { | ||||||
|         super(const AuthenticationState.unknown()) { |  | ||||||
|     _listenForAuthenticationChanges(); |     _listenForAuthenticationChanges(); | ||||||
|   } |   } | ||||||
|   final AuthenticationRepository<Extra> _authenticationRepository; |   final AuthenticationRepository<Extra> authenticationRepository; | ||||||
| 
 | 
 | ||||||
|   void _listenForAuthenticationChanges() { |   void _listenForAuthenticationChanges() { | ||||||
|     _authenticationRepository.streamAccount().listen((accountFutureResult) { |     authenticationRepository.streamAccount().listen((accountFutureResult) { | ||||||
|       accountFutureResult.fold( |       accountFutureResult.fold( | ||||||
|         (value) { |         (value) { | ||||||
|           if (value.account.isNotNull) { |           if (value.account.isNotNull) { | ||||||
|             emit(AuthenticationState<Extra>.authenticated(value)); |             emit(AuthenticationState<Extra>.authenticated(value)); | ||||||
|             return; |             return; | ||||||
|           } |           } | ||||||
|           _authenticationRepository.destroyCache(); |           authenticationRepository.destroyCache(); | ||||||
|           emit(AuthenticationState<Extra>.unauthenticated()); |           emit(AuthenticationState<Extra>.unauthenticated()); | ||||||
|           return; |           return; | ||||||
|         }, |         }, | ||||||
|         (error) { |         (error) { | ||||||
|           _authenticationRepository.destroyCache(); |           authenticationRepository.destroyCache(); | ||||||
|           emit(AuthenticationState<Extra>.unauthenticated()); |           emit(AuthenticationState<Extra>.unauthenticated()); | ||||||
|           return; |           return; | ||||||
|         }, |         }, | ||||||
| @ -58,7 +57,7 @@ class AuthenticationCubit<Extra> extends Cubit<AuthenticationState<Extra>> { | |||||||
|   /// If authenticated, re-emits state with data freshly loaded from cache. |   /// If authenticated, re-emits state with data freshly loaded from cache. | ||||||
|   FutureOr<void> reloadCache() async { |   FutureOr<void> reloadCache() async { | ||||||
|     if (state.status == AuthenticationStatus.authenticated) { |     if (state.status == AuthenticationStatus.authenticated) { | ||||||
|       final data = await _authenticationRepository.getCache(); |       final data = await authenticationRepository.getCache(); | ||||||
|       emit( |       emit( | ||||||
|         data.fold( |         data.fold( | ||||||
|           AuthenticationState<Extra>.authenticated, |           AuthenticationState<Extra>.authenticated, | ||||||
| @ -69,7 +68,6 @@ class AuthenticationCubit<Extra> extends Cubit<AuthenticationState<Extra>> { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   FutureOr<void> signOut() { |   FutureOr<void> signOut() { | ||||||
|     // TODO(hpcl): maybe force unauthenticated by emitting an event |     authenticationRepository.signOut(); | ||||||
|     _authenticationRepository.signOut(); |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -25,14 +25,14 @@ part 'email_verification_state.dart'; | |||||||
| 
 | 
 | ||||||
| class EmailVerificationCubit<Extra> extends Cubit<EmailVerificationState> { | class EmailVerificationCubit<Extra> extends Cubit<EmailVerificationState> { | ||||||
|   EmailVerificationCubit({ |   EmailVerificationCubit({ | ||||||
|     required AuthenticationRepository<Extra> authenticationRepository, |     required this.authenticationRepository, | ||||||
|   })  : _authenticationRepository = authenticationRepository, |   }) : super(const EmailVerificationState()); | ||||||
|         super(const EmailVerificationState()); | 
 | ||||||
|   final AuthenticationRepository<Extra> _authenticationRepository; |   final AuthenticationRepository<Extra> authenticationRepository; | ||||||
| 
 | 
 | ||||||
|   FutureOr<void> sendEmailVerification() async { |   FutureOr<void> sendEmailVerification() async { | ||||||
|     emit(state.copyWith(status: FormStatus.submissionInProgress)); |     emit(state.copyWith(status: FormStatus.submissionInProgress)); | ||||||
|     final response = await _authenticationRepository.sendEmailVerification(); |     final response = await authenticationRepository.sendEmailVerification(); | ||||||
|     emit( |     emit( | ||||||
|       response.fold( |       response.fold( | ||||||
|         (value) => state.copyWith(status: FormStatus.submissionSuccess), |         (value) => state.copyWith(status: FormStatus.submissionSuccess), | ||||||
| @ -47,7 +47,7 @@ class EmailVerificationCubit<Extra> extends Cubit<EmailVerificationState> { | |||||||
|   FutureOr<void> checkEmailVerification() async { |   FutureOr<void> checkEmailVerification() async { | ||||||
|     emit(state.copyWith(status: FormStatus.submissionInProgress)); |     emit(state.copyWith(status: FormStatus.submissionInProgress)); | ||||||
| 
 | 
 | ||||||
|     final refresh = await _authenticationRepository.refresh(); |     final refresh = await authenticationRepository.refresh(); | ||||||
|     if (refresh.isErr) { |     if (refresh.isErr) { | ||||||
|       final refreshError = refresh.err!; |       final refreshError = refresh.err!; | ||||||
|       emit( |       emit( | ||||||
| @ -59,7 +59,7 @@ class EmailVerificationCubit<Extra> extends Cubit<EmailVerificationState> { | |||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     final currentAccount = await _authenticationRepository.getAccount(); |     final currentAccount = await authenticationRepository.getAccount(); | ||||||
|     emit( |     emit( | ||||||
|       currentAccount.fold( |       currentAccount.fold( | ||||||
|         (value) => state.copyWith( |         (value) => state.copyWith( | ||||||
|  | |||||||
| @ -26,17 +26,17 @@ part 'password_reset_state.dart'; | |||||||
| 
 | 
 | ||||||
| class PasswordResetCubit<Extra> extends FormDataCubit<PasswordResetState> { | class PasswordResetCubit<Extra> extends FormDataCubit<PasswordResetState> { | ||||||
|   PasswordResetCubit({ |   PasswordResetCubit({ | ||||||
|     required AuthenticationRepository<Extra> authenticationRepository, |     required this.authenticationRepository, | ||||||
|   })  : _authenticationRepository = authenticationRepository, |   })  :  | ||||||
|         super( |         super( | ||||||
|           PasswordResetState( |           PasswordResetState( | ||||||
|             form: authenticationRepository.formRepository |             form: authenticationRepository.formRepository | ||||||
|                 .accessForm(AuthFormName.passwordResetForm), |                 .accessForm(AuthFormName.passwordResetForm), | ||||||
|           ), |           ), | ||||||
|         ); |         ); | ||||||
|   final AuthenticationRepository<Extra> _authenticationRepository; |   final AuthenticationRepository<Extra> authenticationRepository; | ||||||
|   FormRepository get _formRepository => |   FormRepository get formRepository => | ||||||
|       _authenticationRepository.formRepository; |       authenticationRepository.formRepository; | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   String get formName => AuthFormName.passwordResetForm; |   String get formName => AuthFormName.passwordResetForm; | ||||||
| @ -51,11 +51,11 @@ class PasswordResetCubit<Extra> extends FormDataCubit<PasswordResetState> { | |||||||
|     String key, |     String key, | ||||||
|     FormInputValidator<Value, ValidationError> dirtyValue, |     FormInputValidator<Value, ValidationError> dirtyValue, | ||||||
|   ) { |   ) { | ||||||
|     final form = _formRepository.accessForm(formName).clone(); |     final form = formRepository.accessForm(formName).clone(); | ||||||
| 
 | 
 | ||||||
|     try { |     try { | ||||||
|       form.updateValidator(key, dirtyValue); |       form.updateValidator(key, dirtyValue); | ||||||
|       _formRepository.updateForm(form); |       formRepository.updateForm(form); | ||||||
|     } catch (e) { |     } catch (e) { | ||||||
|       rethrow; |       rethrow; | ||||||
|     } |     } | ||||||
| @ -68,7 +68,7 @@ class PasswordResetCubit<Extra> extends FormDataCubit<PasswordResetState> { | |||||||
|   @override |   @override | ||||||
|   FutureOr<void> reset() { |   FutureOr<void> reset() { | ||||||
|     final form = state.form.reset(); |     final form = state.form.reset(); | ||||||
|     _formRepository.updateForm(form); |     formRepository.updateForm(form); | ||||||
|     emit( |     emit( | ||||||
|       state.copyWith(form: form, status: form.validate()), |       state.copyWith(form: form, status: form.validate()), | ||||||
|     ); |     ); | ||||||
| @ -82,7 +82,7 @@ class PasswordResetCubit<Extra> extends FormDataCubit<PasswordResetState> { | |||||||
| 
 | 
 | ||||||
|     emit(state.copyWith(status: FormStatus.submissionInProgress)); |     emit(state.copyWith(status: FormStatus.submissionInProgress)); | ||||||
| 
 | 
 | ||||||
|     final form = _formRepository.accessForm(formName); |     final form = formRepository.accessForm(formName); | ||||||
|     final email = form.valueOf<String?>(AuthFormField.email); |     final email = form.valueOf<String?>(AuthFormField.email); | ||||||
| 
 | 
 | ||||||
|     if (email.isNullOrEmpty) { |     if (email.isNullOrEmpty) { | ||||||
| @ -94,7 +94,7 @@ class PasswordResetCubit<Extra> extends FormDataCubit<PasswordResetState> { | |||||||
|       ); |       ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     final response = await _authenticationRepository.sendPasswordResetEmail( |     final response = await authenticationRepository.sendPasswordResetEmail( | ||||||
|       email: email!, |       email: email!, | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
| @ -114,9 +114,9 @@ class PasswordResetCubit<Extra> extends FormDataCubit<PasswordResetState> { | |||||||
|     WyattForm form, { |     WyattForm form, { | ||||||
|     SetOperation operation = SetOperation.replace, |     SetOperation operation = SetOperation.replace, | ||||||
|   }) { |   }) { | ||||||
|     final WyattForm current = _formRepository.accessForm(formName).clone(); |     final WyattForm current = formRepository.accessForm(formName).clone(); | ||||||
|     final WyattForm newForm = operation.operation.call(current, form); |     final WyattForm newForm = operation.operation.call(current, form); | ||||||
|     _formRepository.updateForm(newForm); |     formRepository.updateForm(newForm); | ||||||
| 
 | 
 | ||||||
|     emit( |     emit( | ||||||
|       state.copyWith( |       state.copyWith( | ||||||
| @ -130,7 +130,7 @@ class PasswordResetCubit<Extra> extends FormDataCubit<PasswordResetState> { | |||||||
|   FutureOr<void> validate() { |   FutureOr<void> validate() { | ||||||
|     emit( |     emit( | ||||||
|       state.copyWith( |       state.copyWith( | ||||||
|         status: _formRepository.accessForm(formName).validate(), |         status: formRepository.accessForm(formName).validate(), | ||||||
|       ), |       ), | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -24,23 +24,21 @@ part 'sign_in_state.dart'; | |||||||
| 
 | 
 | ||||||
| class SignInCubit<Extra> extends FormDataCubit<SignInState> { | class SignInCubit<Extra> extends FormDataCubit<SignInState> { | ||||||
|   SignInCubit({ |   SignInCubit({ | ||||||
|     required AuthenticationRepository<Extra> authenticationRepository, |     required this.authenticationRepository, | ||||||
|   })  : _authenticationRepository = authenticationRepository, |   }) : super( | ||||||
|         super( |  | ||||||
|           SignInState( |           SignInState( | ||||||
|             form: authenticationRepository.formRepository |             form: authenticationRepository.formRepository | ||||||
|                 .accessForm(AuthFormName.signInForm), |                 .accessForm(AuthFormName.signInForm), | ||||||
|           ), |           ), | ||||||
|         ); |         ); | ||||||
|   final AuthenticationRepository<Extra> _authenticationRepository; |   final AuthenticationRepository<Extra> authenticationRepository; | ||||||
|   FormRepository get _formRepository => |   FormRepository get formRepository => authenticationRepository.formRepository; | ||||||
|       _authenticationRepository.formRepository; |  | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   String get formName => AuthFormName.signInForm; |   String get formName => AuthFormName.signInForm; | ||||||
| 
 | 
 | ||||||
|   void emailChanged(String value) { |   void emailChanged(String value) { | ||||||
|     final emailValidatorType = _formRepository |     final emailValidatorType = formRepository | ||||||
|         .accessForm(formName) |         .accessForm(formName) | ||||||
|         .validatorOf(AuthFormField.email) |         .validatorOf(AuthFormField.email) | ||||||
|         .runtimeType; |         .runtimeType; | ||||||
| @ -54,7 +52,7 @@ class SignInCubit<Extra> extends FormDataCubit<SignInState> { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   void passwordChanged(String value) { |   void passwordChanged(String value) { | ||||||
|     final passwordValidatorType = _formRepository |     final passwordValidatorType = formRepository | ||||||
|         .accessForm(formName) |         .accessForm(formName) | ||||||
|         .validatorOf(AuthFormField.password) |         .validatorOf(AuthFormField.password) | ||||||
|         .runtimeType; |         .runtimeType; | ||||||
| @ -91,11 +89,11 @@ class SignInCubit<Extra> extends FormDataCubit<SignInState> { | |||||||
|     String key, |     String key, | ||||||
|     FormInputValidator<Value, ValidationError> dirtyValue, |     FormInputValidator<Value, ValidationError> dirtyValue, | ||||||
|   ) { |   ) { | ||||||
|     final form = _formRepository.accessForm(formName).clone(); |     final form = formRepository.accessForm(formName).clone(); | ||||||
| 
 | 
 | ||||||
|     try { |     try { | ||||||
|       form.updateValidator(key, dirtyValue); |       form.updateValidator(key, dirtyValue); | ||||||
|       _formRepository.updateForm(form); |       formRepository.updateForm(form); | ||||||
|     } catch (e) { |     } catch (e) { | ||||||
|       rethrow; |       rethrow; | ||||||
|     } |     } | ||||||
| @ -108,7 +106,7 @@ class SignInCubit<Extra> extends FormDataCubit<SignInState> { | |||||||
|   @override |   @override | ||||||
|   FutureOr<void> reset() { |   FutureOr<void> reset() { | ||||||
|     final form = state.form.reset(); |     final form = state.form.reset(); | ||||||
|     _formRepository.updateForm(form); |     formRepository.updateForm(form); | ||||||
|     emit( |     emit( | ||||||
|       state.copyWith(form: form, status: form.validate()), |       state.copyWith(form: form, status: form.validate()), | ||||||
|     ); |     ); | ||||||
| @ -125,9 +123,9 @@ class SignInCubit<Extra> extends FormDataCubit<SignInState> { | |||||||
|     WyattForm form, { |     WyattForm form, { | ||||||
|     SetOperation operation = SetOperation.replace, |     SetOperation operation = SetOperation.replace, | ||||||
|   }) { |   }) { | ||||||
|     final WyattForm current = _formRepository.accessForm(formName).clone(); |     final WyattForm current = formRepository.accessForm(formName).clone(); | ||||||
|     final WyattForm newForm = operation.operation.call(current, form); |     final WyattForm newForm = operation.operation.call(current, form); | ||||||
|     _formRepository.updateForm(newForm); |     formRepository.updateForm(newForm); | ||||||
| 
 | 
 | ||||||
|     emit( |     emit( | ||||||
|       state.copyWith( |       state.copyWith( | ||||||
| @ -141,7 +139,7 @@ class SignInCubit<Extra> extends FormDataCubit<SignInState> { | |||||||
|   FutureOr<void> validate() { |   FutureOr<void> validate() { | ||||||
|     emit( |     emit( | ||||||
|       state.copyWith( |       state.copyWith( | ||||||
|         status: _formRepository.accessForm(formName).validate(), |         status: formRepository.accessForm(formName).validate(), | ||||||
|       ), |       ), | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
| @ -157,7 +155,7 @@ class SignInCubit<Extra> extends FormDataCubit<SignInState> { | |||||||
| 
 | 
 | ||||||
|     emit(state.copyWith(status: FormStatus.submissionInProgress)); |     emit(state.copyWith(status: FormStatus.submissionInProgress)); | ||||||
| 
 | 
 | ||||||
|     final form = _formRepository.accessForm(formName); |     final form = formRepository.accessForm(formName); | ||||||
|     final email = form.valueOf<String?>(AuthFormField.email); |     final email = form.valueOf<String?>(AuthFormField.email); | ||||||
|     final password = form.valueOf<String?>(AuthFormField.password); |     final password = form.valueOf<String?>(AuthFormField.password); | ||||||
| 
 | 
 | ||||||
| @ -170,7 +168,7 @@ class SignInCubit<Extra> extends FormDataCubit<SignInState> { | |||||||
|       ); |       ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     final uid = await _authenticationRepository.signInWithEmailAndPassword( |     final uid = await authenticationRepository.signInWithEmailAndPassword( | ||||||
|       email: email!, |       email: email!, | ||||||
|       password: password!, |       password: password!, | ||||||
|     ); |     ); | ||||||
| @ -193,7 +191,7 @@ class SignInCubit<Extra> extends FormDataCubit<SignInState> { | |||||||
| 
 | 
 | ||||||
|     emit(state.copyWith(status: FormStatus.submissionInProgress)); |     emit(state.copyWith(status: FormStatus.submissionInProgress)); | ||||||
| 
 | 
 | ||||||
|     final uid = await _authenticationRepository.signInAnonymously(); |     final uid = await authenticationRepository.signInAnonymously(); | ||||||
| 
 | 
 | ||||||
|     emit( |     emit( | ||||||
|       uid.fold( |       uid.fold( | ||||||
| @ -213,7 +211,7 @@ class SignInCubit<Extra> extends FormDataCubit<SignInState> { | |||||||
|     // TODO(wyatt): maybe emit new state (to not carry an old errorMessage) |     // TODO(wyatt): maybe emit new state (to not carry an old errorMessage) | ||||||
|     emit(state.copyWith(status: FormStatus.submissionInProgress)); |     emit(state.copyWith(status: FormStatus.submissionInProgress)); | ||||||
| 
 | 
 | ||||||
|     final uid = await _authenticationRepository.signInWithGoogle(); |     final uid = await authenticationRepository.signInWithGoogle(); | ||||||
| 
 | 
 | ||||||
|     emit( |     emit( | ||||||
|       uid.fold( |       uid.fold( | ||||||
|  | |||||||
| @ -26,23 +26,21 @@ part 'sign_up_state.dart'; | |||||||
| 
 | 
 | ||||||
| class SignUpCubit<Extra> extends FormDataCubit<SignUpState> { | class SignUpCubit<Extra> extends FormDataCubit<SignUpState> { | ||||||
|   SignUpCubit({ |   SignUpCubit({ | ||||||
|     required AuthenticationRepository<Extra> authenticationRepository, |     required this.authenticationRepository, | ||||||
|   })  : _authenticationRepository = authenticationRepository, |   }) : super( | ||||||
|         super( |  | ||||||
|           SignUpState( |           SignUpState( | ||||||
|             form: authenticationRepository.formRepository |             form: authenticationRepository.formRepository | ||||||
|                 .accessForm(AuthFormName.signUpForm), |                 .accessForm(AuthFormName.signUpForm), | ||||||
|           ), |           ), | ||||||
|         ); |         ); | ||||||
|   final AuthenticationRepository<Extra> _authenticationRepository; |   final AuthenticationRepository<Extra> authenticationRepository; | ||||||
|   FormRepository get _formRepository => |   FormRepository get formRepository => authenticationRepository.formRepository; | ||||||
|       _authenticationRepository.formRepository; |  | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   String get formName => AuthFormName.signUpForm; |   String get formName => AuthFormName.signUpForm; | ||||||
| 
 | 
 | ||||||
|   void emailChanged(String value) { |   void emailChanged(String value) { | ||||||
|     final emailValidatorType = _formRepository |     final emailValidatorType = formRepository | ||||||
|         .accessForm(formName) |         .accessForm(formName) | ||||||
|         .validatorOf(AuthFormField.email) |         .validatorOf(AuthFormField.email) | ||||||
|         .runtimeType; |         .runtimeType; | ||||||
| @ -56,7 +54,7 @@ class SignUpCubit<Extra> extends FormDataCubit<SignUpState> { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   void passwordChanged(String value) { |   void passwordChanged(String value) { | ||||||
|     final passwordValidatorType = _formRepository |     final passwordValidatorType = formRepository | ||||||
|         .accessForm(formName) |         .accessForm(formName) | ||||||
|         .validatorOf(AuthFormField.password) |         .validatorOf(AuthFormField.password) | ||||||
|         .runtimeType; |         .runtimeType; | ||||||
| @ -93,11 +91,11 @@ class SignUpCubit<Extra> extends FormDataCubit<SignUpState> { | |||||||
|     String key, |     String key, | ||||||
|     FormInputValidator<Value, ValidationError> dirtyValue, |     FormInputValidator<Value, ValidationError> dirtyValue, | ||||||
|   ) { |   ) { | ||||||
|     final form = _formRepository.accessForm(formName).clone(); |     final form = formRepository.accessForm(formName).clone(); | ||||||
| 
 | 
 | ||||||
|     try { |     try { | ||||||
|       form.updateValidator(key, dirtyValue); |       form.updateValidator(key, dirtyValue); | ||||||
|       _formRepository.updateForm(form); |       formRepository.updateForm(form); | ||||||
|     } catch (e) { |     } catch (e) { | ||||||
|       rethrow; |       rethrow; | ||||||
|     } |     } | ||||||
| @ -110,7 +108,7 @@ class SignUpCubit<Extra> extends FormDataCubit<SignUpState> { | |||||||
|   @override |   @override | ||||||
|   FutureOr<void> reset() { |   FutureOr<void> reset() { | ||||||
|     final form = state.form.reset(); |     final form = state.form.reset(); | ||||||
|     _formRepository.updateForm(form); |     formRepository.updateForm(form); | ||||||
|     emit( |     emit( | ||||||
|       state.copyWith(form: form, status: form.validate()), |       state.copyWith(form: form, status: form.validate()), | ||||||
|     ); |     ); | ||||||
| @ -124,7 +122,7 @@ class SignUpCubit<Extra> extends FormDataCubit<SignUpState> { | |||||||
| 
 | 
 | ||||||
|     emit(state.copyWith(status: FormStatus.submissionInProgress)); |     emit(state.copyWith(status: FormStatus.submissionInProgress)); | ||||||
| 
 | 
 | ||||||
|     final form = _formRepository.accessForm(formName); |     final form = formRepository.accessForm(formName); | ||||||
|     final email = form.valueOf<String?>(AuthFormField.email); |     final email = form.valueOf<String?>(AuthFormField.email); | ||||||
|     final password = form.valueOf<String?>(AuthFormField.password); |     final password = form.valueOf<String?>(AuthFormField.password); | ||||||
| 
 | 
 | ||||||
| @ -137,7 +135,7 @@ class SignUpCubit<Extra> extends FormDataCubit<SignUpState> { | |||||||
|       ); |       ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     final uid = await _authenticationRepository.signUp( |     final uid = await authenticationRepository.signUp( | ||||||
|       email: email!, |       email: email!, | ||||||
|       password: password!, |       password: password!, | ||||||
|     ); |     ); | ||||||
| @ -158,9 +156,9 @@ class SignUpCubit<Extra> extends FormDataCubit<SignUpState> { | |||||||
|     WyattForm form, { |     WyattForm form, { | ||||||
|     SetOperation operation = SetOperation.replace, |     SetOperation operation = SetOperation.replace, | ||||||
|   }) { |   }) { | ||||||
|     final WyattForm current = _formRepository.accessForm(formName).clone(); |     final WyattForm current = formRepository.accessForm(formName).clone(); | ||||||
|     final WyattForm newForm = operation.operation.call(current, form); |     final WyattForm newForm = operation.operation.call(current, form); | ||||||
|     _formRepository.updateForm(newForm); |     formRepository.updateForm(newForm); | ||||||
| 
 | 
 | ||||||
|     emit( |     emit( | ||||||
|       state.copyWith( |       state.copyWith( | ||||||
| @ -174,7 +172,7 @@ class SignUpCubit<Extra> extends FormDataCubit<SignUpState> { | |||||||
|   FutureOr<void> validate() { |   FutureOr<void> validate() { | ||||||
|     emit( |     emit( | ||||||
|       state.copyWith( |       state.copyWith( | ||||||
|         status: _formRepository.accessForm(formName).validate(), |         status: formRepository.accessForm(formName).validate(), | ||||||
|       ), |       ), | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user