Skip to content

Commit

Permalink
Merge pull request #5 from finkmoritz/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
finkmoritz committed May 14, 2021
2 parents 6bb0f3c + ff5a8c6 commit 7bb6dd2
Show file tree
Hide file tree
Showing 8 changed files with 419 additions and 25 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.1.1

- Support Amplify configurations with phone number as username
- Added support for several required attributes, including address, name, website and many more

## 0.1.0

- Initial version
37 changes: 30 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,55 @@ Flutter plugin that automatically generates authentication widget templates base
## Features

### SignInPage
- Sign in via password and
- username or
- email
- Sign in via password and one of the following
- username
- email
- phone number
- Sign in as guest (if configured)
- Sign in with social providers:
- Facebook
- Google
- Amazon

### SignUpPage
- Sign up via username, password and email address (plus confirmation code)
- Sign up via password and one of the following (plus confirmation code):
- username
- email
- phone number
- Additional required attributes (if configured):
- Address
- Street address
- Locality
- Region
- Postal code
- Country
- Email
- Phone number
- Nickname
- Preferred username
- Name
- Given name
- Middle name
- Family name
- Gender
- Date of Birth
- Picture
- Profile
- Website
- Updated at

### PasswordResetPage
- Reset password via confirmation code and
- username or
- Reset password via confirmation code and one of the following
- username
- email
- phone number

## Install

To use this plugin, add `flutter_amplify_auth_ui` as a `dev_dependency` in your pubspec.yaml:
```
dev_dependencies:
flutter_amplify_auth_ui: ^0.1.0
flutter_amplify_auth_ui: ^0.1.1
```

Run `flutter pub get` to install the plugin.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter_amplify_auth_ui/src/template_handlers/template_handler.d
class SignInPageTemplateHandler extends TemplateHandler {
static const List<String> configurableUsernameAttributes = [
'email',
'phone_number',
];
static const List<String> configurableAuthProviders = [
'Facebook',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,25 @@ import 'package:flutter_amplify_auth_ui/src/template_handlers/template_handler.d

class SignUpPageTemplateHandler extends TemplateHandler {
static const List<String> configurableRequiredAttributes = [
'address',
'birthdate',
'email',
'family_name',
'gender',
'given_name',
'middle_name',
'name',
'nickname',
'birthdate',
'phone_number',
'preferred_username',
'profile',
'picture',
'updated_at',
'website',
];
static const List<String> configurableUsernameAttributes = [
'email',
'phone_number',
];

@override
Expand Down
49 changes: 43 additions & 6 deletions lib/templates/password_management/password_reset_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class _PasswordResetPageState extends State<PasswordResetPage> {
/*+++START usernameAttributes[email]+++*/
final TextEditingController _emailController = TextEditingController();
/*+++END usernameAttributes[email]+++*/
/*+++START usernameAttributes[phone_number]+++*/
final TextEditingController _phoneNumberController = TextEditingController();
/*+++END usernameAttributes[phone_number]+++*/
final TextEditingController _passwordController = TextEditingController();
final TextEditingController _confirmationCodeController = TextEditingController();

Expand All @@ -32,6 +35,9 @@ class _PasswordResetPageState extends State<PasswordResetPage> {
/*+++START usernameAttributes[email]+++*/
_emailController.dispose();
/*+++END usernameAttributes[email]+++*/
/*+++START usernameAttributes[phone_number]+++*/
_phoneNumberController.dispose();
/*+++END usernameAttributes[phone_number]+++*/
_passwordController.dispose();
_confirmationCodeController.dispose();
super.dispose();
Expand Down Expand Up @@ -143,7 +149,7 @@ class _PasswordResetPageState extends State<PasswordResetPage> {
TextFormField(
controller: _usernameController,
decoration: InputDecoration(
icon: Icon(Icons.person),
icon: Icon(Icons.person_outline),
hintText: 'Enter your username',
labelText: 'Username'
),
Expand All @@ -152,13 +158,25 @@ class _PasswordResetPageState extends State<PasswordResetPage> {
/*+++START usernameAttributes[email]+++*/
TextFormField(
controller: _emailController,
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
icon: Icon(Icons.mail),
icon: Icon(Icons.mail_outline),
hintText: 'Enter your email address',
labelText: 'Email address'
),
),
/*+++END usernameAttributes[email]+++*/
/*+++START usernameAttributes[phone_number]+++*/
TextFormField(
controller: _phoneNumberController,
keyboardType: TextInputType.phone,
decoration: InputDecoration(
icon: Icon(Icons.phone_outlined),
hintText: 'Enter your phone number',
labelText: 'Phone number'
),
),
/*+++END usernameAttributes[phone_number]+++*/
],
);
}
Expand All @@ -173,7 +191,7 @@ class _PasswordResetPageState extends State<PasswordResetPage> {
TextFormField(
controller: _usernameController,
decoration: InputDecoration(
icon: Icon(Icons.person),
icon: Icon(Icons.person_outline),
hintText: 'Enter your username',
labelText: 'Username'
),
Expand All @@ -182,26 +200,39 @@ class _PasswordResetPageState extends State<PasswordResetPage> {
/*+++START usernameAttributes[email]+++*/
TextFormField(
controller: _emailController,
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
icon: Icon(Icons.mail),
icon: Icon(Icons.mail_outline),
hintText: 'Enter your email address',
labelText: 'Email address'
),
),
/*+++END usernameAttributes[email]+++*/
/*+++START usernameAttributes[phone_number]+++*/
TextFormField(
controller: _phoneNumberController,
keyboardType: TextInputType.phone,
decoration: InputDecoration(
icon: Icon(Icons.phone_outlined),
hintText: 'Enter your phone number',
labelText: 'Phone number'
),
),
/*+++END usernameAttributes[phone_number]+++*/
TextFormField(
controller: _passwordController,
obscureText: true,
decoration: InputDecoration(
icon: Icon(Icons.lock),
icon: Icon(Icons.lock_outline),
hintText: 'Enter your new password',
labelText: 'New password'
),
),
TextFormField(
controller: _confirmationCodeController,
keyboardType: TextInputType.number,
decoration: InputDecoration(
icon: Icon(Icons.check),
icon: Icon(Icons.check_outlined),
hintText: 'Enter confirmation code',
labelText: 'Confirmation code'
),
Expand All @@ -219,6 +250,9 @@ class _PasswordResetPageState extends State<PasswordResetPage> {
/*+++START usernameAttributes[email]+++
username: _emailController.text.trim(),
+++END usernameAttributes[email]+++*/
/*+++START usernameAttributes[phone_number]+++
username: _phoneNumberController.text.trim(),
+++END usernameAttributes[phone_number]+++*/
);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('Successfully sent confirmation code'),
Expand All @@ -241,6 +275,9 @@ class _PasswordResetPageState extends State<PasswordResetPage> {
/*+++START usernameAttributes[email]+++
username: _emailController.text.trim(),
+++END usernameAttributes[email]+++*/
/*+++START usernameAttributes[phone_number]+++
username: _phoneNumberController.text.trim(),
+++END usernameAttributes[phone_number]+++*/
newPassword: _passwordController.text.trim(),
confirmationCode: _confirmationCodeController.text.trim(),
);
Expand Down
27 changes: 24 additions & 3 deletions lib/templates/sign_in/sign_in_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class _SignInPageState extends State<SignInPage> {
/*+++START usernameAttributes[email]+++*/
final TextEditingController _emailController = TextEditingController();
/*+++END usernameAttributes[email]+++*/
/*+++START usernameAttributes[phone_number]+++*/
final TextEditingController _phoneNumberController = TextEditingController();
/*+++END usernameAttributes[phone_number]+++*/
final TextEditingController _passwordController = TextEditingController();

@override
Expand All @@ -33,6 +36,9 @@ class _SignInPageState extends State<SignInPage> {
/*+++START usernameAttributes[email]+++*/
_emailController.dispose();
/*+++END usernameAttributes[email]+++*/
/*+++START usernameAttributes[phone_number]+++*/
_phoneNumberController.dispose();
/*+++END usernameAttributes[phone_number]+++*/
_passwordController.dispose();
super.dispose();
}
Expand All @@ -55,7 +61,7 @@ class _SignInPageState extends State<SignInPage> {
TextFormField(
controller: _usernameController,
decoration: InputDecoration(
icon: Icon(Icons.person),
icon: Icon(Icons.person_outline),
hintText: 'Enter your username',
labelText: 'Username'
),
Expand All @@ -64,18 +70,30 @@ class _SignInPageState extends State<SignInPage> {
/*+++START usernameAttributes[email]+++*/
TextFormField(
controller: _emailController,
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
icon: Icon(Icons.mail),
icon: Icon(Icons.mail_outline),
hintText: 'Enter your email address',
labelText: 'Email address'
),
),
/*+++END usernameAttributes[email]+++*/
/*+++START usernameAttributes[phone_number]+++*/
TextFormField(
controller: _phoneNumberController,
keyboardType: TextInputType.phone,
decoration: InputDecoration(
icon: Icon(Icons.phone_outlined),
hintText: 'Enter your phone number',
labelText: 'Phone number'
),
),
/*+++END usernameAttributes[phone_number]+++*/
TextFormField(
controller: _passwordController,
obscureText: true,
decoration: InputDecoration(
icon: Icon(Icons.lock),
icon: Icon(Icons.lock_outline),
hintText: 'Enter your password',
labelText: 'Password'
),
Expand Down Expand Up @@ -172,6 +190,9 @@ class _SignInPageState extends State<SignInPage> {
/*+++START usernameAttributes[email]+++
username: _emailController.text.trim(),
+++END usernameAttributes[email]+++*/
/*+++START usernameAttributes[phone_number]+++
username: _phoneNumberController.text.trim(),
+++END usernameAttributes[phone_number]+++*/
password: _passwordController.text.trim(),
);
if(result.isSignedIn) {
Expand Down

0 comments on commit 7bb6dd2

Please sign in to comment.