fix(authentication): allow email/password validators customization (closes #57)
This commit was merged in pull request #60.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
// -----
|
||||
// File: app.dart
|
||||
// Created Date: 19/08/2022 12:05:38
|
||||
// Last Modified: Wed Nov 23 2022
|
||||
// Last Modified: Sat Dec 03 2022
|
||||
// -----
|
||||
// Copyright (c) 2022
|
||||
|
||||
@@ -13,6 +13,7 @@ import 'dart:math';
|
||||
import 'package:example_router/core/constants/form_field.dart';
|
||||
import 'package:example_router/core/dependency_injection/get_it.dart';
|
||||
import 'package:example_router/core/routes/router.dart';
|
||||
import 'package:example_router/core/utils/custom_password.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
@@ -47,6 +48,7 @@ class App extends StatelessWidget {
|
||||
authenticationRemoteDataSource: getIt<AuthenticationRemoteDataSource>(),
|
||||
onSignUpSuccess: onSignUpSuccess,
|
||||
onAuthChange: onAccountChanges,
|
||||
customPasswordValidator: const CustomPassword.pure(),
|
||||
extraSignUpInputs: [
|
||||
FormInput(
|
||||
AppFormField.confirmedPassword,
|
||||
|
||||
+7
-3
@@ -3,10 +3,11 @@
|
||||
// -----
|
||||
// File: sign_in_form.dart
|
||||
// Created Date: 19/08/2022 15:24:37
|
||||
// Last Modified: Wed Nov 16 2022
|
||||
// Last Modified: Sat Dec 03 2022
|
||||
// -----
|
||||
// Copyright (c) 2022
|
||||
|
||||
import 'package:example_router/core/utils/custom_password.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wyatt_authentication_bloc/wyatt_authentication_bloc.dart';
|
||||
import 'package:wyatt_form_bloc/wyatt_form_bloc.dart';
|
||||
@@ -38,7 +39,8 @@ class _PasswordInput extends StatelessWidget {
|
||||
field: AuthFormField.password,
|
||||
builder: ((context, cubit, state, field, input) {
|
||||
return TextField(
|
||||
onChanged: (pwd) => cubit.passwordChanged(pwd),
|
||||
onChanged: (pwd) => cubit
|
||||
.passwordCustomChanged<CustomPassword>(CustomPassword.dirty(pwd)),
|
||||
obscureText: true,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Password',
|
||||
@@ -59,7 +61,9 @@ class _SignInButton extends StatelessWidget {
|
||||
return status.isSubmissionInProgress
|
||||
? const CircularProgressIndicator()
|
||||
: ElevatedButton(
|
||||
onPressed: status.isValidated ? () => cubit.signInWithEmailAndPassword() : null,
|
||||
onPressed: status.isValidated
|
||||
? () => cubit.signInWithEmailAndPassword()
|
||||
: null,
|
||||
child: const Text('Sign in with credentials'),
|
||||
);
|
||||
}),
|
||||
|
||||
+4
-2
@@ -3,11 +3,12 @@
|
||||
// -----
|
||||
// File: sign_up_form.dart
|
||||
// Created Date: 19/08/2022 14:41:08
|
||||
// Last Modified: Wed Nov 16 2022
|
||||
// Last Modified: Sat Dec 03 2022
|
||||
// -----
|
||||
// Copyright (c) 2022
|
||||
|
||||
import 'package:example_router/core/constants/form_field.dart';
|
||||
import 'package:example_router/core/utils/custom_password.dart';
|
||||
import 'package:flutter/material.dart' hide FormField;
|
||||
import 'package:wyatt_authentication_bloc/wyatt_authentication_bloc.dart';
|
||||
import 'package:wyatt_form_bloc/wyatt_form_bloc.dart';
|
||||
@@ -40,7 +41,8 @@ class _PasswordInput extends StatelessWidget {
|
||||
builder: ((context, cubit, state, field, input) {
|
||||
return TextField(
|
||||
onChanged: (pwd) {
|
||||
cubit.passwordChanged(pwd);
|
||||
cubit.passwordCustomChanged<CustomPassword>(
|
||||
CustomPassword.dirty(pwd));
|
||||
cubit.dataChanged(
|
||||
AppFormField.confirmedPassword,
|
||||
ConfirmedPassword.dirty(
|
||||
|
||||
Reference in New Issue
Block a user