Reputation: 85775
I have logout button on my site, When clicked their authentication is removed and they are sent back to the home page.
I was using
browserHistory.push({ pathname: '/home' });
but I noticed that if I would hit the "back" button after being logged out they would sort of go back to the previous logged in page(they would see nothing as they have no authentication).
I would like to remove the history so they can't go back.
So I tried
browserHistory.replace({ pathname: '/home' });
this also did not work.
Upvotes: 8
Views: 25050
Reputation: 8102
Hi It's great to see your progress while implementing optimized authentication in your app. You need to make sure that your history stack is maintained properly. I think you have always used history.push
even going back. This is going to make a trouble. Try to use goBack(), go(n)
for programmatically and for browser back button use replace, push
where needed. You history stack should be aligned with browser back button.
Upvotes: 1
Reputation: 800
As far as I know, it's not possible.
I'd recommend you to check user auth on pages that require users to be authenticated and redirect them to the login page using browserHistory.replace
. So if the user clicks back after logout the will see login page again.
Upvotes: 1