Closed mooreds closed 5 months ago
Not sure if this is part of the same issue or not, but will post this here until confirmed otherwise. When I login for the first time (when the access_token
cookie doesn't exist and the POST /token-exchange
endpoint is called), the user
cookie is correctly populated. However, when I logout and then log back in, the access_token
cookie remains the same, and the user
cookie is set to the string undefined
.
Hmm, seems to me that the access_token
needs to be removed on logout.
Hmm, seems to me that the
access_token
needs to be removed on logout.
Yeah, that's what I was thinking as well. Is that something that should be handled on my side? Or something that the SDK should be taking care of?
I think the SDK should handle that. I think we can get that fixed in the next few days.
I'm going to track the access cookie remaining in a separate issue: https://github.com/FusionAuth/fusionauth-react-sdk/issues/27
Okay, heard a bit from one of the devs who wrote this. They pointed me to https://github.com/FusionAuth/fusionauth-example-react-sdk/blob/main/server/routes/token-exchange.js#L35 and said that for some reason it isn't being populated. Need to do some more research.
Looking at the provider code, there are some instances where user
and isAuthenticated
are not set at the same time. There are cases where they may be out of sync. We can adjust the code to handle these and add tests to watch for future breakage.
This PR inadvertently addresses some of it — we can address the rest once it goes in.
The issue I am seeing is that the user object from the sdk is just an empty object. The “isAuthenticated” property is being correctly populated though.
This results in
user
being set to an empty object:{}
andisAuthenticated
beingtrue
.I am able to get the user by just reading the cookie myself, but it seems like
user
should be set.It looks like
setUser
is configured here: https://github.com/FusionAuth/fusionauth-react-sdk/blob/main/src/providers/FusionAuthProvider.tsx#L56and it seems like
useEffect
should be setting the user object here: https://github.com/FusionAuth/fusionauth-react-sdk/blob/main/src/providers/FusionAuthProvider.tsx#L127 but theuseFusionAuth
method doesn't return a valid user.