Hi, I am using Amplify authenticator in my react app. In my app component i check authenticated user (using useAuthenticator) and if it is not null the route leads to Home component. But, on landing and interacting in Home component, the user becomes null again leading me back to authentication page again. I check in localstorage that the amplify auth fields also get removed. DOes anyone have clue why it's behaving this way?
#App logging out automatically after authenication by Authenticator
8 messages · Page 1 of 1 (latest)
Hi @robust nova, just to clarify you are saying that when you checked local storage the fields were indeed removed?
Also how do you have your Authenticator in place in your app? Are you wrapping the entire app in Authenticator or Authenticator.Provider?
Can you share a bit more of your code
Thanks @untold slate for quick response. Yes, the fields are removed as i check localstorage of browser.
Also, I am wrapping my entire app with Authenticator.provider in index.js file (there are multiple wrappers, if that matters) :
<React.StrictMode>
<BrowserRouter>
<AppContextProvider>
<Authenticator.Provider>
<Provider store={store}>
<App />
</Provider>
</Authenticator.Provider>
</AppContextProvider>
</BrowserRouter>
</React.StrictMode>
In my App, I get the user as : const { user, signOut } = useAuthenticator((context) => [context.user]);
And on presence of a valid user, routing to Home component as : <Route exact path="/" element={user?<Home/>:<LandingMain/>} />
Hmm that’s interesting. I don’t see anything wrong with it from how you have it
Would you mind opening up an issue in the JS repo with as much details as possible so that I can look into it more tomorrow
Sure @untold slate . I will add the details in an issue. Apologies for late response, as i was occupied with travel. Thanks for the direction.
@untold slate created an issue with details and screen recording : https://github.com/aws-amplify/amplify-js/issues/11302
awesome thank you for opening this, I will look into it and get back to you on the issue itself!