netlify-labs / react-netlify-identity

a tiny (4kb) React hook for using Netlify Identity, no UI. SEEKING MAINTAINERS
https://netlify-gotrue-in-react.netlify.com/
156 stars 25 forks source link

Authenticated API not returning a user after a period of inactivity #43

Closed LuigiClaudio closed 3 years ago

LuigiClaudio commented 3 years ago

Hi, I'm new to this and I've started putting together an app that uses the react-netlify-identity bindings in order to achieve the level of flexibility I wanted for the authentication flow using Netlify Identity.

I've been experiences the following issue: After a period of inactivity (I guess the one hour the token is valid), and given that remember was left to its default true, the user is shown as logged is however when checking the current context by pinging the authenticated API using for example the authedFetch method, no user object seems to exists. I can only see the identity object.

Am I missing any logic for handling such scenario?

I have the working app at this address https://toask.netlify.app/ - it's connected to FaunaDB using Apollo client for handling a list of plain todo list. This uses the context.user.sub to associate a list of todos to a user and as you can image, with the scanario mentioned above, no data is returned when no sub is found in the context.

If I log out the user from useIdentityContext(), the user object is correctly returned it would seem.

Anyone can suggest what I should look out for?

LuigiClaudio commented 3 years ago

https://github.com/netlify-labs/react-netlify-identity/issues/44