aws-samples / aws-samples/amplify-vite-react-template

Unexpected Behavor at implementing Per User Authorization Feature.

Open
#7 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
109
Forks
261
PR merge metrics
No merged PRs in 30d

Description

*Issue Explanation:*

While doing the Quickstart guide for the Amplify Gen-2 I found a confuse behavor at implementing the per user authorization feature.
Here:
![image](https://github.com/aws-samples/amplify-vite-react-template/assets/54689488/ff9ef468-eee7-4f57-b4d5-afe6cb092d83)

Due to the initial code of the *amplify-vite-react-template* at `App.tsx` the Per User Authorization feature won't work correctly, because if the user changes between to accounts to validate that the Per User Authorization works, the data got stock to the previous account:

https://github.com/aws-samples/amplify-vite-react-template/assets/54689488/21367b71-4e44-4d29-bbd6-b9039b126d48

In the example above, the account with email: **agustin.moranr@gmail.com** has 2 todos items written in Spanish, while the other account: **agustin.moranr+2@gmail.com** has 2 todos items written in English. As you can see when changing the account, the data got stuck and i need to reload the page to update the data.

I think this is not expected to happened because in the quickstart guide you are meant to use subscription method to query your data.

*Request of changes:*

I think one of the easiest ways of solving this is moving the TodosList to a separated component.
Something like this:

![image](https://github.com/aws-samples/amplify-vite-react-template/assets/54689488/547e4dcf-73f4-4a72-b521-f99692b75704)
![image](https://github.com/aws-samples/amplify-vite-react-template/assets/54689488/34545e6e-7d38-4ef4-9c4b-c2e9f0fd5cd2)

This way when the user implements the `Authenticator` component, the `TodosList` will be unmounted and mounted correctly, and updating subscription query data, retrieving the expected data for each user.

Maybe you can upadate the quickstart documentation to handle this properly, or maybe updating the template also would work!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.