Logging out from system #167
-
Hi, I followed the instructions on https://docs.fief.dev/integrate/javascript/frontend/react/ to implement a login/logout mechanism in React. it works great when I place the code for https://docs.fief.dev/integrate/javascript/frontend/react/#manage-authentication in the main page. In my web service there's a dashboard where only logged in users can access. when a logged in user is in the dashboard and tries to logout, he automatically return to the callback page where he is redirected to fief login page.
The code in the main page:
On App.js i use this route which is the only route using
Do you need more info? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
When you call Make sure this URL points to a "public" page, otherwise, they will be redirected back to the login page. Also, I see that your |
Beta Was this translation helpful? Give feedback.
So, after investigating, it seems that there is a race condition between
<RequireAuth>
and the logout redirection. When we calllogout
, it clears the session from the storage, which triggers a re-render of<RequireAuth>
and prevent the redirection to logout from happening.I'll see how to improve this in the SDK.
In the meantime, an easy solution is to implement a public
<Logout>
page which calls thelogout
method. Then, in your user menu, just make a link to this page.