Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(amplify_authenticator): text overflow & validation fixes #786

Merged
Merged
Show file tree
Hide file tree
Changes from 101 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
3791441
feat: :sparkles: first snippet for the amplify authenticator
israx Jul 12, 2021
2c2e895
docs: :memo: update of license & project's description
israx Jul 12, 2021
8b3e129
feat(amplify_auth_cognito): add initial example app for the authentic…
israx Jul 15, 2021
4c87471
iOS & Android files
israx Jul 15, 2021
5a1f9c7
feat(amplify_authenticator): screens implementation -Sign In, Sign Up…
israx Jul 15, 2021
1e67acd
dependecies & project's name updated
israx Jul 15, 2021
d744d99
feat(amplify_authenticator): button disable for auth calls
israx Jul 15, 2021
ba63722
Fix: user not able to sign out
israx Jul 16, 2021
f33c324
Merge branch 'amplify-authenticator' into amplify-authenticator
israx Jul 16, 2021
f9ef45e
closing brace
israx Jul 16, 2021
85b6537
test directory deleted
israx Jul 16, 2021
a69d9b8
fix: AuthFormField(type: 'password') is able to hide values
israx Jul 16, 2021
0918835
feat: default & custom validators
israx Jul 16, 2021
67acfc3
refactor: signin, signup & confirm signup view models
israx Jul 18, 2021
27cc823
docs: initial documentation
israx Jul 19, 2021
a08615a
chore: keys in form fields and buttons
israx Jul 19, 2021
857b729
chore: keys in form fields and buttons
israx Jul 19, 2021
955f485
test: integration test setup
israx Jul 20, 2021
8857fdc
feat: custom form field
israx Jul 20, 2021
6d3cc96
refactor: nullable auth variables in confirm sign up, sign in and sig…
israx Jul 20, 2021
1e14609
refactor: boilerplate from example app
israx Jul 20, 2021
29f42fa
refactor: amplify_configure.dart deleted
israx Jul 20, 2021
45b4d93
test: sign in screen integration testing
israx Jul 20, 2021
6c96135
doc: public members
israx Jul 21, 2021
998c5cb
refactor: form field keys
israx Jul 21, 2021
69afbac
refactor: using types
israx Jul 21, 2021
04925a3
refactor: sign out method
israx Jul 21, 2021
37b03ac
refactor: handle result from sign in / up calls
israx Jul 22, 2021
69cea2e
test: sign in integration testing
israx Jul 23, 2021
7f9cb78
test: sign up integration testing
israx Jul 24, 2021
dccd7ba
refactor: enums in signup, signin and confirm_signup form fields
israx Jul 24, 2021
187de14
feat: confirm sign in screen
israx Jul 26, 2021
3d2373e
Update amplify_authenticator.dart
israx Jul 26, 2021
0c5ab32
refactor: late keyword removed
israx Jul 27, 2021
3f117f1
refactor: getCurrentUser() method
israx Jul 27, 2021
78ed359
refactor: return type of currentUser method
israx Jul 27, 2021
becac00
print() removed
israx Jul 27, 2021
4ee3d5a
refactor: copy/paste error
israx Jul 27, 2021
1650dd3
refactor: non-null types
israx Jul 27, 2021
8bc0af5
refactor: non-null type
israx Jul 27, 2021
0f2ba1b
refactor: void Function()
israx Jul 27, 2021
1ee5f60
refactor: return null types in form field types
israx Jul 27, 2021
359fe71
refactor: null return type
israx Jul 27, 2021
395bc83
Update signin_types.dart
israx Jul 27, 2021
3c607cd
refactor: null return type
israx Jul 27, 2021
ae89f52
refactor: pr comments
israx Jul 27, 2021
f959275
Merge branch 'amplify-authenticator' of github.com:israx/amplify-flut…
israx Jul 27, 2021
5981480
test: confirm sign in integration test
israx Jul 27, 2021
399342e
refactor: code removed
israx Jul 27, 2021
9687907
Merge branch 'amplify-authenticator' into amplify-authenticator
israx Jul 27, 2021
b0f9c14
Merge branch 'amplify-authenticator' of github.com:aws-amplify/amplif…
israx Jul 28, 2021
853c5d8
Merge branch 'amplify-authenticator' of github.com:israx/amplify-flut…
israx Jul 28, 2021
d690287
fix: unsed code
israx Jul 28, 2021
b86c532
fix
israx Jul 28, 2021
5dd44ac
feat: display exceptions widget
israx Jul 29, 2021
483bf10
Extra lines removed
israx Jul 29, 2021
4f00cdc
extra lines
israx Jul 29, 2021
29c072c
chore: extra lines
israx Jul 29, 2021
640f48b
feat: username alias
israx Jul 30, 2021
e660dce
feat: resend code button in confirm sign up screen |
israx Jul 30, 2021
bc65e08
feat: rest password option enabled
israx Jul 31, 2021
7acc8f9
feat: reset password screen
israx Jul 31, 2021
55df1ad
feat: confirm sign in with new password screen
israx Aug 2, 2021
245229f
fix(authenticator): SignInFormField pointing to the same instance |
israx Aug 3, 2021
0db76e7
fix: form field pointing to same instance
israx Aug 3, 2021
20ef464
refactor: update password
israx Aug 3, 2021
b85a18b
refactor: keys
israx Aug 3, 2021
1f0fb1b
Merge branch 'amplify-authenticator' of github.com:israx/amplify-flut…
israx Aug 3, 2021
e451946
Merge branch 'amplify-authenticator' of github.com:aws-amplify/amplif…
israx Aug 3, 2021
146457d
refactor: branch conflicts
israx Aug 3, 2021
f0eec5a
fix: confirm password username attribute
israx Aug 3, 2021
ae9e514
fix: second clause for non-Amplify exceptions
israx Aug 4, 2021
9b034bf
refactor: clearException method for clearing all exceptions in the
israx Aug 4, 2021
bc5a439
refactor: clearException method
israx Aug 4, 2021
e65483f
refactor: non null exception controller
israx Aug 4, 2021
b1e6151
fix: throw error when signInStep == 'CONFIRM_SIGN_IN_WITH_CUSTOM_CHAL…
israx Aug 4, 2021
0a18042
refactor: error objects
israx Aug 4, 2021
1b89757
feat: user is signed in after confirm sign up and when sign up respon…
israx Aug 4, 2021
2945a65
feat: confirm sign in auth flow
israx Aug 5, 2021
3eb65d9
refactor: show sign in screen after sign out
israx Aug 5, 2021
f68145e
refactor: const variable
israx Aug 5, 2021
182f85c
chore: unnecessary enum deleted
israx Aug 5, 2021
f22b0cd
refactor: non-null & final declaration
israx Aug 5, 2021
360b4ee
chore: commented code removed
israx Aug 5, 2021
5dcae48
refactor: VMs updated based on the triggered state
israx Aug 5, 2021
171f0e0
refactor: resend code method
israx Aug 5, 2021
bb680eb
refactor: validators in form fields
israx Aug 5, 2021
a6da6ed
fix: null value in a variable at confirm sign up VM
israx Aug 5, 2021
9fd2c57
refactor: authenticator container padding
israx Aug 5, 2021
01eb4af
refactor: else clause in Authenticator Stream Builder
israx Aug 5, 2021
8b7ffd0
refactor: username alias optional
israx Aug 5, 2021
2242296
doc: finders in intergarion testion
israx Aug 5, 2021
03fed5c
doc: finders
israx Aug 5, 2021
b1d2e68
doc: username alias doc
israx Aug 5, 2021
95c9160
refactor: inherited forms
israx Aug 5, 2021
97f8403
fix: overflow in exception widget
israx Aug 5, 2021
6ee2a32
fix: validation in confirm sign up form fields.
israx Aug 6, 2021
c1daf21
refactor: null check (!) removed from inherited forms
israx Aug 6, 2021
704aaf3
feat: loading state in sign out button if there's any exception.
israx Aug 6, 2021
0a5941c
fix: overflow in buttons
israx Aug 6, 2021
e233118
chore: commented code removed
israx Aug 6, 2021
3d3f3ce
refactor: public methods in AuthBloc
israx Aug 6, 2021
6f235e8
Merge branch 'amplify-authenticator' of github.com:aws-amplify/amplif…
israx Aug 6, 2021
4b7db7b
fix: unsued code
israx Aug 6, 2021
3b4b2d7
chore: empty test
israx Aug 6, 2021
87fef7a
fix: customer unable to see missing form fields.
israx Aug 6, 2021
0a5546c
refactor: firstWhere method in VMs
israx Aug 6, 2021
8d05cef
refactor: expanded widget
israx Aug 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:amplify_authenticator/src/keys.dart';

/// Find specific widgets in the widget tree based on their keys
final codeConfirmSignInFormFieldFinder =
find.byKey(const Key(keyCodeConfirmSignInFormfield));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:amplify_authenticator/src/keys.dart';

/// Find specific widgets in the widget tree based on their keys
final usernameConfirmSignUpFormFieldFinder =
find.byKey(const Key(keyUsernameConfirmSignUpFormfield));
final codeConfirmSignUpFormFieldFinder =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:amplify_authenticator/src/keys.dart';

/// Find specific widgets in the widget tree based on their keys
final usernameSignInFormFieldFinder =
find.byKey(const Key(keyUsernameSignInFormfield));
find.byKey(const Key(keyUsernameSignInFormField));
final emailSignInFormFieldFinder =
find.byKey(const Key(keyEmailSignInFormfield));
find.byKey(const Key(keyEmailSignInFormField));
final phoneNumberSignInFormFieldFinder =
find.byKey(const Key(keyPhoneNumberSignInFormfield));
find.byKey(const Key(keyPhoneNumberSignInFormField));
final passwordSignInFormFieldFinder =
find.byKey(const Key(keyPasswordSignInFormfield));
find.byKey(const Key(keyPasswordSignInFormField));
final signInButtonFinder = find.byKey(const Key(keySignInButton));
final signOutButtonFinder = find.byKey(const Key(keySignOutButton));
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:amplify_authenticator/src/keys.dart';

/// Find specific widgets in the widget tree based on their keys
final usernameSignUpFormFieldFinder =
find.byKey(const Key(keyUsernameSignUpFormField));
final emailSignUpFormFieldFinder =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:amplify_authenticator/src/keys.dart';

/// Find specific widgets in the widget tree based on their keys
final inheritedAuthViewModelFinder =
find.byKey(const Key(keyInheritedAuthViewModel));
final inheritedAuthBlocFinder = find.byKey(const Key(keyInheritedAuthBloc));
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ void main() {
await tester.enterText(codeConfirmSignUpFormFieldFinder, mockCode);
await Future<void>.delayed(const Duration(seconds: 2));


//For now, this screen uses a mocked code and doesn't call the
// confirmSignUp method.

Expand Down
1 change: 0 additions & 1 deletion packages/amplify_authenticator/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_flutter/amplify.dart';
import 'package:flutter/material.dart';
import 'package:amplify_authenticator/amplify_authenticator.dart';

import 'amplifyconfiguration.dart';

void main() {
Expand Down
126 changes: 82 additions & 44 deletions packages/amplify_authenticator/lib/amplify_authenticator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@

library amplify_authenticator;

import 'package:amplify_authenticator/src/keys.dart';
import 'package:amplify_authenticator/src/screens/confirm_signin_screen.dart';
import 'package:flutter/material.dart';
import 'package:amplify_authenticator/src/keys.dart';

//State
import 'package:amplify_authenticator/src/state/inherited_forms.dart';
Expand All @@ -29,6 +28,10 @@ import 'package:amplify_authenticator/src/screens/loading_screen.dart';
import 'package:amplify_authenticator/src/screens/signin_screen.dart';
import 'package:amplify_authenticator/src/screens/signup_screen.dart';
import 'package:amplify_authenticator/src/screens/confirm_signup_screen.dart';
import 'package:amplify_authenticator/src/screens/send_code_screen.dart';
import 'package:amplify_authenticator/src/screens/confirm_signin_new_password.dart';
import 'package:amplify_authenticator/src/screens/reset_password_screen.dart';
import 'package:amplify_authenticator/src/screens/confirm_signin_mfa_screen.dart';

//Bloc
import 'package:amplify_authenticator/src/blocs/auth/auth_data.dart';
Expand All @@ -40,38 +43,41 @@ import 'package:amplify_authenticator/src/views/signup_viewmodel.dart';
import 'package:amplify_authenticator/src/views/confirm_signup_viewmodel.dart';
import 'package:amplify_authenticator/src/views/confirm_signin_viewmodel.dart';

//Enums
import 'package:amplify_authenticator/src/enums/alias.dart';

//Services
import 'package:amplify_authenticator/src/services/amplify_auth_service.dart';

//Widgets
import 'package:amplify_authenticator/src/widgets/forms.dart';
import 'package:amplify_authenticator/src/widgets/default_forms.dart';
import 'package:amplify_authenticator/src/widgets/auth_exceptions.dart';

//Exports
export 'package:amplify_authenticator/src/enums/alias.dart';
export 'package:amplify_authenticator/src/widgets/forms.dart';
export 'package:amplify_authenticator/src/widgets/form_fields.dart';
export 'package:amplify_authenticator/src/widgets/buttons.dart'
show SignOutButton;

///
// ignore: must_be_immutable
class Authenticator extends StatefulWidget {
///# Amplify Authenticator
///
/// A widget that allows customers to authenticate their apps.
///
///This wrapper requires a child widget to be passed as an argument.
///To work with custom forms there is the need to pass up to 3 additional
///arguments, signInForm, signUpForm and confirmSignInForm with their
///respective form fields.
///The Authenticator widget requires two arguments, a child widget and an username alias
///to define the initial authentication flow.
///
///This authenticator accepts the following custom forms, sign in, sign up and confirm sign in.
///
///Note that working with custom forms is optional. Thus, if no additional arguments
///are passed, the authenticator will defined the following default forms with their
///respective form fields:
///
/// 1. Sign in:
/// - Username
/// - Alias (username, email or phone number)
/// - Password
/// 2. Sign Up:
/// - Username
Expand All @@ -83,22 +89,40 @@ class Authenticator extends StatefulWidget {
/// - define
/// - define
///
Authenticator(

{required this.child,
SignInForm? signInForm,
SignUpForm? signUpForm,
ConfirmSignInForm? confirmSignInForm}) {
this.signInForm = signInForm ?? DefaultForms.signInForm();
this.signUpForm = signUpForm ?? DefaultForms.signUpForm();
this.confirmSignInForm =
confirmSignInForm ?? DefaultForms.confirmSignInForm();
Authenticator({
Alias? usernameAlias,
required this.child,
SignInForm? signInForm,
SignUpForm? signUpForm,
ConfirmSignInMFAForm? confirmSignInFormMFA,
}) {
this.usernameAlias = usernameAlias ?? Alias.username;
this.signInForm = signInForm ?? DefaultForms.signInForm(this.usernameAlias);
this.signUpForm = signUpForm ?? DefaultForms.signUpForm(this.usernameAlias);
this.confirmSignInMFAForm =
confirmSignInFormMFA ?? DefaultForms.confirmSignInForm();

confirmSignUpForm = DefaultForms.confirmSignUpForm(this.usernameAlias);
sendCodeForm = DefaultForms.sendCodeForm(this.usernameAlias);
resetPasswordForm = DefaultForms.resetPasswordForm();
confirmSignInNewPasswordForm = DefaultForms.confirmSignInNewPasswordForm();
}

{required this.child, SignInForm? signInForm, SignUpForm? signUpForm}) {
this.signInForm = signInForm ?? DefaultForms.signInForm();
this.signUpForm = signUpForm ?? DefaultForms.signUpForm();
///Optional username alias to setup the preferred sign in method,
///which can be signing in users with username, email or phone number.
///
/// ```dart
/// Alias.username
/// Alias.email
/// Alias.phone_number
/// Alias.email_phone_number
/// ```
late Alias usernameAlias;

}
late SendCodeForm sendCodeForm;
late ConfirmSignUpForm confirmSignUpForm;
late ResetPasswordForm resetPasswordForm;
late final ConfirmSignInMFAForm confirmSignInMFAForm;

/// This form will support the following form field types:
/// * username
Expand Down Expand Up @@ -172,9 +196,6 @@ class Authenticator extends StatefulWidget {
/// ```
late final SignUpForm signUpForm;

final ConfirmSignUpForm confirmSignUpForm = DefaultForms.confirmSignUpForm();


/// This form will support the following form field types:
/// * code
/// * password
Expand All @@ -199,11 +220,11 @@ class Authenticator extends StatefulWidget {
///
/// ### Example
/// ```dart
/// ConfirmSignInForm( formFields:
/// ConfirmSignInNewPasswordForm( formFields:
/// FormFields(children: [
/// ConfirmSignInFormField(
/// type: "code" ,
/// title: "Custom code form field",
/// type: "email" ,
/// title: "Custom email form field",
/// hintText: "Custom hint text",
/// ),
/// ConfirmSignInFormField(
Expand All @@ -216,12 +237,10 @@ class Authenticator extends StatefulWidget {
///
/// ```

late final ConfirmSignInForm confirmSignInForm;
late ConfirmSignInNewPasswordForm confirmSignInNewPasswordForm;


/// This widget will be displayed after a user has signed in with some verified credentials.
final Widget child;

final Widget child;

@override
_AuthenticatorState createState() => _AuthenticatorState();
Expand Down Expand Up @@ -250,20 +269,21 @@ class _AuthenticatorState extends State<Authenticator> {
signUpViewModel: SignUpViewModel(_stateMachineBloc),
confirmSignUpViewModel: ConfirmSignUpViewModel(_stateMachineBloc),
confirmSignInViewModel: ConfirmSignInViewModel(_stateMachineBloc),

child: InheritedForms(
confirmSignInNewPasswordForm:
widget.confirmSignInNewPasswordForm,
resetPasswordForm: widget.resetPasswordForm,
sendCodeForm: widget.sendCodeForm,
signInForm: widget.signInForm,
signUpForm: widget.signUpForm,
confirmSignUpForm: widget.confirmSignUpForm,
confirmSignInForm: widget.confirmSignInForm,

confirmSignInMFAForm: widget.confirmSignInMFAForm,
child: Scaffold(
body: StreamBuilder(
stream: _stateMachineBloc.stream,
builder: (context, snapshot) {
final state = snapshot.data ?? const AuthLoading();

Widget? screen;
late Widget screen;
if (state is AuthLoading) {
screen = LoadingScreen();
} else if (state is Authenticated) {
Expand All @@ -278,14 +298,32 @@ class _AuthenticatorState extends State<Authenticator> {
state.screen == AuthScreen.confirmSignUp) {
screen = ConfirmSignUpScreen();
} else if (state is AuthFlow &&
state.screen == AuthScreen.confirmSignIn) {
screen = ConfirmSignInScreen();

state.screen == AuthScreen.confirmSignInMfa) {
screen = const ConfirmSignInMFAScreen();
} else if (state is AuthFlow &&
state.screen == AuthScreen.confirmSignInNewPassword) {
screen = ConfirmSignInNewPasswordScreen();
} else if (state is AuthFlow &&
state.screen == AuthScreen.sendCode) {
screen = const SendCodeScreen();
} else if (state is AuthFlow &&
state.screen == AuthScreen.resetPassword) {
screen = const ResetPasswordScreen();
} else {
screen = SignInScreen();
}

return Center(
child: SingleChildScrollView(
child: screen,
return Container(
padding: const EdgeInsets.symmetric(vertical: 40),
child: Center(
child: SingleChildScrollView(
child: Column(
children: [
const AuthExceptionsWidget(),
screen,
],
),
),
),
);
},
Expand All @@ -296,6 +334,6 @@ class _AuthenticatorState extends State<Authenticator> {
@override
void dispose() {
_stateMachineBloc.dispose();
super.dispose();
super.dispose();
}
}
Loading