You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My application works with 3rd party API only so I'm going to serve files statically (and I.m unable to initialize the store on the server).
Because of that my app is always redirected to /login before user is loaded and added to the store.
It would be nice to have example or recommendations how to handle this case.
I have following workaround, but I don't like it:
const UserIsAuthenticated = UserAuthWrapper({
authSelector: state => {
return {
wasRequested: state.isLoggedUserRequested,
data: state.entities.loggedUser
};
},
redirectAction: (path) => replaceState(null, path.pathname, path.query),
wrapperDisplayName: 'UserIsAuthenticated',
allowRedirectBack: false,
predicate: user => {
// logged user has not been requested yet - redirect to /login page is not required
if (!user.wasRequested) {
return true;
}
// user has been requested but user is not logged - redirect to /signin
else if (user.wasRequested && isEmpty(user.data)) {
return false;
}
return true;
}
});
isLoggedUserRequested is set to true when request to /users/me has been completed.
The text was updated successfully, but these errors were encountered:
@apedyashev thanks for the issue. I think its somewhat related to the discussions in #10 (comment). I think one solution would be to have an isAuthenticating/isLoggingIn selector and an optional component to display while this is true. If false, the normal auth flow kicks in.
My application works with 3rd party API only so I'm going to serve files statically (and I.m unable to initialize the store on the server).
Because of that my app is always redirected to /login before user is loaded and added to the store.
It would be nice to have example or recommendations how to handle this case.
I have following workaround, but I don't like it:
isLoggedUserRequested
is set to true when request to /users/me has been completed.The text was updated successfully, but these errors were encountered: