-
Notifications
You must be signed in to change notification settings - Fork 305
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
Issue related to the authStatus update in the useAuthenticator hook #4788
Comments
@zackseyun Can you verify whether you are using the |
I am using the Here is my full file for using both for reference:
|
Can you define what you mean by "much delay"? After signin there's an extra API call after signin in order to populate the user, which is then used by the authstatus, but I can't reproduce much of a delay. Are you able to share a video or quantify how much delay you are seeing? |
actually reviewing the issue again, the issue isnt a delay, its a misuse of the authStatus as a way to know whether a user just signed-in/create-an-account. I'm thinking of a new approach. My goal is to redirect users to a specific page ("/Chat") immediately after they successfully sign in or create an account. To achieve this, I plan to use a custom onSignIn callback that sets a local state (justSignedIn) to true. This state will be used in a useEffect hook to trigger the redirection. Relevant New Code Snippet:
Issue: I am unsure how to correctly pass this onSignIn callback to the Authenticator component in Amplify UI React v6. The existing documentation does not clearly illustrate how to handle custom post-authentication actions or how to integrate custom callbacks with the Authenticator component. If it could be implemented this way, I'm sure this would fix my issue. |
Ok I fixed it. Explaining the problem and the solution here for posterity. There was no issue with AWS amplify/cognito, but rather the issue was my using of dynamic loading and imports. Rebase the problem:
Solution:
Relevant solution snippet:
|
this issue can be closed |
@zackseyun Thanks for the heads up and glad you were able to find a solution |
hey @nadetastic, I'm experiencing an issue related to the authStatus update in the useAuthenticator hook. My application's components are conditionally rendered based on the authStatus. However, I've noticed that there's a delay in the authStatus changing to 'authenticated' after a successful sign-in. This delay causes a mismatch between the actual authentication state and the UI representation.
So by the time authStatus is triggered the useEffect,
if (authStatus === 'authenticated')
is evaluating to false. but when I print to my console to see the value of authStatus, it is indeed"authenticated"
, but only after much delay.What else I tried:
I also considered using the
isSignedIn
function from the migration guide, but then I'd have to manage more aspects of the authentication process.https://docs.amplify.aws/javascript/build-a-backend/troubleshooting/migrate-from-javascript-v5-to-v6/#4-upgrade-category-usage
Do you have a suggestion on an alternative method? I tried as many different methods to no avail and really would like to not install my own delay for these processes, and seems like this should be very simple. (This v6 upgrade has been so cumbersome I tried reverting to v5, but it seemed I wouldnt be able to use amplify ui-react without using v6). Appreciate your help~
Relevant code snippet:
(ill make this my last question so i dont keep trailing, but this documentation is very sparse)
Originally posted by @zackseyun in aws-amplify/amplify-js#12594 (comment)
The text was updated successfully, but these errors were encountered: