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

refactor(authenticator)!: use Amplify JS auto sign in #2642

Merged
merged 90 commits into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from 88 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
911af7b
First commit on xstate changes
Aug 4, 2022
98efa20
continued updates for auto sign in
Aug 4, 2022
457be52
Updated auto-sign in for manual and auto sign ups
Aug 4, 2022
b2bee53
Update auto sign in
Aug 16, 2022
6dafa29
Merged main in
Sep 20, 2022
ed5316a
Configured to always use auto sign up
Sep 20, 2022
527396b
Began fixing tests
Sep 21, 2022
5023728
Fixing tests
Sep 21, 2022
7aa9c26
fixed tests
Sep 21, 2022
1ba2335
Updated router config
Sep 22, 2022
a2486d0
Updated logic for xstate
Sep 22, 2022
fefc95c
Added new run actor state
Sep 23, 2022
8daa424
Fixed route config
Sep 24, 2022
62908e9
Cleaned up code
Sep 24, 2022
7bc21c4
created and merged next release branch
Sep 24, 2022
8dc0621
Added more tests
Sep 24, 2022
bcceb6f
Updated test
Sep 24, 2022
a1436bd
Updated test
Sep 24, 2022
0d610f0
Trying to fix tests...
Sep 25, 2022
3467df6
Trying to fix tests....
Sep 25, 2022
c3974d1
trying to fix tests....
Sep 25, 2022
9552757
Updated tests...
Sep 25, 2022
2dddb2f
Trying to fix tests....
Sep 25, 2022
03a14ed
Added additional documentation
Sep 28, 2022
82b6930
removed console.logs
Sep 28, 2022
6ac5761
Merged main back in
Sep 28, 2022
a9f9cea
Fixed angular
Sep 29, 2022
f0b3db0
Added explicit instructions to update to the latest version of the aw…
Sep 29, 2022
4bb3a92
fixed test
Sep 29, 2022
9508de0
merged next-release/main in, fixed conflict in yarn.lock
Sep 30, 2022
00760c7
Create cuddly-insects-pump.md
wlee221 Oct 4, 2022
94d7c7f
Create neat-houses-heal.md
wlee221 Oct 4, 2022
8ed414a
Create brown-lies-wonder.md
wlee221 Oct 4, 2022
f05d473
Reverted overrides
Oct 12, 2022
b3c273c
Merged main in
Oct 12, 2022
8337857
Updated docs
Oct 12, 2022
be15de6
Fixed issue with vue-tsc
Oct 13, 2022
b65f6cf
Merged main in
Oct 13, 2022
9e77483
Added in more docs
Oct 13, 2022
428e79f
Updated migration docs
Oct 13, 2022
e853a1b
Fixed spelling mistake
Oct 17, 2022
c7c617c
Merged main in
Oct 17, 2022
c565986
Updated based on code review
Oct 17, 2022
db2c22d
Refactored defaultAuthServices out and made some minor changes based …
Oct 18, 2022
0025d09
Fixed test
Oct 18, 2022
17f5164
Updated migration guides
Oct 19, 2022
9dc7974
chore: wait for state machine to be in autoSignIn state (#2760)
wlee221 Oct 19, 2022
e76ed3d
Merge branch 'next-release/main' into next-release/auto-sign-in
Oct 19, 2022
d916134
Updated based on PR feedback
Oct 19, 2022
3de0945
Fixed bug in tests
Oct 19, 2022
62acced
Update docs/src/pages/[platform]/connected-components/authenticator/c…
wlee221 Oct 19, 2022
b3bf553
Added new transition
Oct 20, 2022
60ce109
Fixed test
Oct 20, 2022
3aa61dc
Fixed more tests
Oct 20, 2022
82efea1
Update fix for autoSignIn issue
Oct 21, 2022
0ba9d05
Merge branch 'next-release/main' into next-release/auto-sign-in
Oct 21, 2022
37b6a03
Merge branch 'next-release/main' into next-release/auto-sign-in
ErikCH Oct 22, 2022
6f7b7a0
Fix
Oct 22, 2022
1296da2
Remove duplicate conditions
wlee221 Oct 22, 2022
4aeb2c4
Remove unnecessary onError cases
wlee221 Oct 23, 2022
726e7cc
Simplify experssion
wlee221 Oct 23, 2022
d97541f
Revert "Remove unnecessary onError cases"
wlee221 Oct 23, 2022
62fcffb
Use event.data instead of context.actorDoneData
wlee221 Oct 23, 2022
79475a7
Remove unnecessary onError cases
wlee221 Oct 23, 2022
bafd962
Fixed conflicts, merged main in
Oct 24, 2022
c4d0d82
Updated changeset
Oct 24, 2022
c15aec2
Updated sign-up-with-email removed extra context.route
Oct 24, 2022
fd53856
updated changerequest file
Oct 24, 2022
1160810
Merge branch 'next-release/main' into next-release/auto-sign-in
ErikCH Oct 24, 2022
7b06bcd
Updates from code review
Oct 25, 2022
dc99477
Supplement comment for waitFor
wlee221 Oct 25, 2022
a81f953
Merge branch 'next-release/auto-sign-in' of github.com:aws-amplify/am…
wlee221 Oct 25, 2022
3e41112
Use named export
wlee221 Oct 25, 2022
48dc2dc
Merge branch 'next-release/main' into next-release/auto-sign-in
wlee221 Oct 25, 2022
58ddc79
chore: update yarn.lock file (#2806)
reesscot Oct 25, 2022
778d252
Merge branch 'next-release/main' into next-release/auto-sign-in
reesscot Oct 25, 2022
aaea89c
Merge pull request #2808 from aws-amplify/next-release/auto-sign-in-y…
reesscot Oct 25, 2022
80f7df5
Added comment on routes facade
Oct 25, 2022
2bba986
Merge branch 'next-release/main' into next-release/auto-sign-in
ErikCH Oct 25, 2022
e42f6ef
explicit type for hub handler
wlee221 Oct 25, 2022
3904354
Merge branch 'next-release/auto-sign-in' of github.com:aws-amplify/am…
wlee221 Oct 25, 2022
1dc1124
Add comment
wlee221 Oct 25, 2022
d62e688
Update packages/ui/src/helpers/authenticator/facade.ts
wlee221 Oct 25, 2022
eae9d71
Whitespace push
Oct 25, 2022
df07dff
Merge branch 'next-release/main' into next-release/auto-sign-in
ErikCH Oct 27, 2022
650a9c3
Updated migration docs based on feedback
Oct 28, 2022
58c89d6
Updated migration docs
Oct 28, 2022
d132b2e
fixed typos
Oct 31, 2022
7ff9cd7
whitespace push
Oct 31, 2022
b458299
Merge branch 'next-release/main' into next-release/auto-sign-in
wlee221 Oct 31, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions .changeset/brown-lies-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
"@aws-amplify/ui-react": patch
"@aws-amplify/ui": patch
ErikCH marked this conversation as resolved.
Show resolved Hide resolved
"@aws-amplify/ui-angular": patch
"@aws-amplify/ui-vue": patch
---

**BREAKING**: When overriding `Auth.signUp`, update the override function call to include the `autoSignIn` option set to enabled. This is now required.

```diff
async handleSignUp(formData) {
let { username, password, attributes } = formData;
// custom username
username = username.toLowerCase();
attributes.email = attributes.email.toLowerCase();
return Auth.signUp({
username,
password,
attributes,
+ autoSignIn: {
+ enabled: true
+ }
});
}

```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Fragment } from '@/components/Fragment';
import { ResponsiveTable, ResponsiveTableCell } from '@/components/ResponsiveTable';
import { TableCell, TableBody, TableHead, TableRow } from '@aws-amplify/ui-react';
import { TableCell, TableBody, TableHead, TableRow, Alert } from '@aws-amplify/ui-react';

## Override Function Calls

Expand All @@ -10,12 +10,17 @@ To override a call you must create a new `services` object with an `async` `hand
The service object must then be passed into the `authenticator` component as a `services` prop. For example, let's imagine you'd like to lowercase the `username` and the `email` attributes during `signUp`.
This would be overriden like so:

<Alert role="none" variation="warning" heading="Sign Up Auto Sign In">
When overriding `signUp` you must include the `autoSignIn` key and set `enabled` to true, as show in the example below.
</Alert>

<Fragment>
{({ platform }) => import(`./overrides/username.${platform}.mdx`)}
</Fragment>

Each `handle*` function will return the neccessary values you'll need to make the call to the `Auth.*` function call. Here is a table of each override function name, and the values returned from `formData`.


Each `handle*` function will return the neccessary values you'll need to make the call to the `Auth.*` function call. Here is a table of each override function name, and the values returned from `formData`.
<ResponsiveTable labelWidth="10rem">
<TableHead>
<TableRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export class SignUpWithEmailComponent implements OnInit {
username,
password,
attributes,
autoSignIn: {
enabled: true,
},
});
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export default function AuthenticatorWithEmail() {
username,
password,
attributes,
autoSignIn: {
enabled: true,
},
});
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
username,
password,
attributes,
autoSignIn: {
enabled: true,
},
});
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,68 @@
import { Tabs, TabItem } from '@aws-amplify/ui-react';
import { Alert } from '@aws-amplify/ui-react';

## 2.x to 3.x
### Installation
Install the 3.x version of the `@aws-amplify/ui-angular` library and the 5.x version of the `aws-amplify` library.

<Tabs>
<TabItem title="npm">

```shell
npm install aws-amplify@5.x @aws-amplify/ui-angular@3.x
```

</TabItem>
<TabItem title="yarn">
```shell
yarn add aws-amplify@5.x @aws-amplify/ui-angular@3.x
```

</TabItem>
</Tabs>

### Update and usage

The following breaking changes were introduced in `@aws-amplify/ui-angular` major version `3.0`:

#### 1. Automatic signin on signup logic moved to `aws-amplify`.

If you are overriding `Auth.signUp`, update the override function call to include the `autoSignIn` option set to `enabled`. If this change is not made, users will not be automatically signed in on signup.

```diff
async handleSignUp(formData) {
let { username, password, attributes } = formData;
// custom username
username = username.toLowerCase();
attributes.email = attributes.email.toLowerCase();
return Auth.signUp({
username,
password,
attributes,
+ autoSignIn: {
+ enabled: true
+ }
});
}

```

## 1.x to 2.x
## Installation

Install the latest version of the `@aws-amplify/ui-angular` library.
Install the 2.x version of the `@aws-amplify/ui-angular` library.

<Tabs>
<TabItem title="npm">

```shell
npm install aws-amplify @aws-amplify/ui-angular@latest
npm install aws-amplify @aws-amplify/ui-angular@2.x
```

</TabItem>
<TabItem title="yarn">
```shell
yarn add aws-amplify @aws-amplify/ui-angular@latest
yarn add aws-amplify @aws-amplify/ui-angular@2.x
```

</TabItem>
Expand Down Expand Up @@ -87,20 +134,20 @@ Below is an example of how to create an Authenticator.

## Breaking changes

The latest version of the `Authenticator` component has several differences from earlier versions. Here are a few of the major changes that you'll need to look out for.
The 2.x version of the `Authenticator` component has several differences from earlier versions. Here are a few of the major changes that you'll need to look out for.

### Slots

All the slot locations have changed with the latest version of the `Authenticator`. To get a
All the slot locations have changed with the 2.x version of the `Authenticator`. To get a
sense of the changes please check out the [Headers and Footers](../connected-components/authenticator/customization#headers--footers) section.

### Form Fields

The latest version of the `Authenticator` has a different format for the `formFields` prop. It also no long accepts
`inputProps` nor `hint`. Instead it's recommended that you use the [Headers and Footers Slots](../connected-components/authenticator/customization#headers--footers) or use the
The 2.x version of the `Authenticator` has a different format for the `formFields` prop. It also no longer accepts
`inputProps` nor `hint`. Instead, it's recommended that you use the [Headers and Footers Slots](../connected-components/authenticator/customization#headers--footers) or use the
[Sign Up Fields custimization](../connected-components/authenticator/customization#sign-up-fields). For more information on form field customizations
please see the [Form Field Customization](../connected-components/authenticator/customization#form-field-customization) section.

### CSS Styling

The latest version of the `Authenticator` has a completely different set of CSS variables. Please look over the [Amplify CSS Variables](../connected-components/authenticator/customization#styling) section for more information.
The 2.x version of the `Authenticator` has a completely different set of CSS variables. Please look over the [Amplify CSS Variables](../connected-components/authenticator/customization#styling) section for more information.
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import { Alert } from '@aws-amplify/ui-react';

## 3.x to 4.x
### Installation
Install the 4.x version of the `@aws-amplify/ui-react` library.
Install the 4.x version of the `@aws-amplify/ui-react` library and the 5.x version of the `aws-amplify` library.

<Tabs>
<TabItem title="npm">

```shell
npm install aws-amplify @aws-amplify/ui-react@4.x
npm install aws-amplify@5.x @aws-amplify/ui-react@4.x
```

</TabItem>
<TabItem title="yarn">
```shell
yarn add aws-amplify @aws-amplify/ui-react@4.x
yarn add aws-amplify@5.x @aws-amplify/ui-react@4.x
```

</TabItem>
Expand Down Expand Up @@ -79,6 +79,28 @@ Hopefully this change won't affect your code but will allow for more customizati
The TextAreaField component does apply 1 style prop directly on the `textarea` element: `resize`. We felt this one makes sense to apply direclty on the the `textarea` element and not the wrapper element.
</Alert>

#### 5. Automatic signin on signup logic moved to `aws-amplify`.

If you are overriding `Auth.signUp`, update the override function call to include the `autoSignIn` option set to `enabled`. If this change is not made, users will not be automatically signed in on signup.

```diff
async handleSignUp(formData) {
let { username, password, attributes } = formData;
// custom username
username = username.toLowerCase();
attributes.email = attributes.email.toLowerCase();
return Auth.signUp({
username,
password,
attributes,
+ autoSignIn: {
+ enabled: true
+ }
});
}

```

## 2.x to 3.x

### Installation
Expand Down Expand Up @@ -186,8 +208,8 @@ sense of the changes please check out the [Headers and Footers](../connected-com

#### Form Fields

The latest version of the `Authenticator` has a different format for the `formFields` prop. It also no long accepts
`inputProps` nor `hint`. Instead it's recommended that you use the [Headers and Footers Slots](../connected-components/authenticator/customization#headers--footers) or use the
The latest version of the `Authenticator` has a different format for the `formFields` prop. It also no longer accepts
`inputProps` nor `hint`. Instead, it's recommended that you use the [Headers and Footers Slots](../connected-components/authenticator/customization#headers--footers) or use the
[Sign Up Fields customization](../connected-components/authenticator/customization#sign-up-fields). For more information on form field customizations
please see the [Form Field Customization](../connected-components/authenticator/customization#form-field-customization) section.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,74 @@
import { Tabs, TabItem } from '@aws-amplify/ui-react';
import { Alert } from '@aws-amplify/ui-react';

## 2.x to 3.x
### Installation
For Vue.js 2 users please continue to use our legacy library found [here](https://github.com/aws-amplify/amplify-ui/tree/legacy/legacy/amplify-ui-vue).

Install the 3.x version of the `@aws-amplify/ui-vue` library and the 5.x version of the `aws-amplify` library.

<Tabs>
<TabItem title="npm">

```shell
npm install aws-amplify@5.x @aws-amplify/ui-vue@3.x
```

</TabItem>
<TabItem title="yarn">
```shell
yarn add aws-amplify@5.x @aws-amplify/ui-vue@3.x
```

</TabItem>
</Tabs>

### Update and usage

The following breaking changes were introduced in `@aws-amplify/ui-vue` major version `3.0`:

#### 1. Automatic signin on signup logic moved to `aws-amplify`.

If you are overriding `Auth.signUp`, update the override function call to include the `autoSignIn` option set to `enabled`. If this change is not made, users will not be automatically signed in on signup.

```diff
async handleSignUp(formData) {
let { username, password, attributes } = formData;
// custom username
username = username.toLowerCase();
attributes.email = attributes.email.toLowerCase();
return Auth.signUp({
username,
password,
attributes,
+ autoSignIn: {
+ enabled: true
+ }
});
}

```

## 1.x to 2.x
## Installation

For Vue.js 2 users please continue to use our legacy library found [here](https://github.com/aws-amplify/amplify-ui/tree/legacy/legacy/amplify-ui-vue).

For Vue.js 3 users please continue on with the following steps:

Install the latest version of the `@aws-amplify/ui-vue` library.
Install the 2.x version of the `@aws-amplify/ui-vue` library.

<Tabs>
<TabItem title="npm">

```shell
npm install aws-amplify @aws-amplify/ui-vue@latest
npm install aws-amplify @aws-amplify/ui-vue@2
```

</TabItem>
<TabItem title="yarn">
```shell
yarn add aws-amplify @aws-amplify/ui-vue@latest
yarn add aws-amplify @aws-amplify/ui-vue@2
```

</TabItem>
Expand Down Expand Up @@ -93,20 +142,20 @@ Below is an example of how to create an Authenticator.

## Breaking changes

The latest version of the `Authenticator` component has several differences from earlier versions. Here are a few of the major changes that you'll need to look out for.
The 2.x version of the `Authenticator` component has several differences from earlier versions. Here are a few of the major changes that you'll need to look out for.

### Slots

All the slot locations have changed with the latest version of the `Authenticator`. To get a
All the slot locations have changed with the 2.x version of the `Authenticator`. To get a
sense of the changes please check out the [Headers and Footers](../connected-components/authenticator/customization#headers--footers) section.

### Form Fields

The latest version of the `Authenticator` has a different format for the `formFields` prop. It also no long accepts
`inputProps` nor `hint`. Instead it's recommended that you use the [Headers and Footers Slots](../connected-components/authenticator/customization#headers--footers) or use the
The 2.x version of the `Authenticator` has a different format for the `formFields` prop. It also no longer accepts
`inputProps` nor `hint`. Instead, it's recommended that you use the [Headers and Footers Slots](../connected-components/authenticator/customization#headers--footers) or use the
[Sign Up Fields custimization](../connected-components/authenticator/customization#sign-up-fields). For more information on form field customizations
please see the [Form Field Customization](../connected-components/authenticator/customization#form-field-customization) section.

### CSS Styling

The latest version of the `Authenticator` has a completely different set of CSS variables. Please look over the [Amplify CSS Variables](../connected-components/authenticator/customization#styling) section for more information.
The 2.x version of the `Authenticator` has a completely different set of CSS variables. Please look over the [Amplify CSS Variables](../connected-components/authenticator/customization#styling) section for more information.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
let-user="user"
let-signOut="signOut"
>
<h2>Welcome, {{ user.username }}!</h2>
wlee221 marked this conversation as resolved.
Show resolved Hide resolved
<h2>Welcome, {{ user.attributes?.email }}!</h2>
<button (click)="signOut()">Sign Out</button>
</ng-template>
</amplify-authenticator>
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export class SignUpWithEmailComponent implements OnInit {
username,
password,
attributes,
autoSignIn: {
enabled: true,
},
});
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { Amplify } from 'aws-amplify';

import { withAuthenticator } from '@aws-amplify/ui-react';
import { withAuthenticator, Text } from '@aws-amplify/ui-react';
import '@aws-amplify/ui-react/styles.css';

import awsExports from './aws-exports';
Amplify.configure(awsExports);

function App({ signOut }) {
return <button onClick={signOut}>Sign out</button>;
function App({ signOut, user }) {
return (
<>
<Text>{user.attributes?.email}</Text>
<button onClick={signOut}>Sign out</button>
</>
);
}

export default withAuthenticator(App, {
Expand Down