how to remove anonymous user and go to login page
Opened this issue · 3 comments
Deleted user commented
I don't know if this is the right place to ask this but when you start the app, It goes directly to the anonymous user, how to remove this behavior and go to the login page instead, thanks.
cloudmu commented
A quick fix would be to add the following in App.js
componentWillMount() {
const { user } = this.props;
const { router } = this.context;
// If this page is restricted, go to loginPage first.
// (But pass on this page's path in order to redirect back upon login)
if (!user) {
const path = this.props.location.pathname;
router.push(`/login?redirect=${path}`);
}
}
But this may not be bullet-proof, but should get you going. I will check in a better solution when I have time.
Deleted user commented
It does the trick, thanks and keep up the good work!
Deleted user commented
Hello, with the new react router 4, this code to redirect no longer works, any hint on how to do this , thanks for your work.