Closed mn22nw closed 8 years ago
Since I was using redux-simple-router I found a solution by adding dispatch(updatePath('/dashboard')); after the user is authenticated in auth.js
That way, the user get's redirected to the dashboard if they reload the page
If I reload the page when I am at the dashboard path (requires authentication) it redirects me to the start page even when I'm logged in...
This is (I think) due to the initial state for the user being ANONYMOUS and when reloading the app it takes a brief time for it to dispatch the LOGIN_USER action-type and set the auth.currently to LOGGED_IN instead of ANONYMOUS
At least long enough for it the home component to mount before the status is LOGGED_IN.
What I want to happen:
In home.js I've tried redirecting at componentDidMount() but as I wrote earlier the current auth status is Anonymous by then and therfore ignores the redirect.
Same goes for the higher-ordered component authenticatedComponent.js where I also to make a redirect if the user is not logged in.