-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react-admin always remembers users last visited view. #4971
Comments
The problem seems to be in the useLogin hook. const useLogin = (): Login => {
const authProvider = useAuthProvider();
const location = useLocation();
const locationState = location.state as any;
const history = useHistory();
const nextPathName = locationState && locationState.nextPathname;
const login = useCallback(
(params: any = {}, pathName = defaultAuthParams.afterLoginUrl) =>
authProvider.login(params).then(ret => {
// --> nextPathName gets used every time if exists
history.push(nextPathName || pathName);
return ret;
}),
[authProvider, history, nextPathName]
);
const loginWithoutProvider = useCallback(
(_, __) => {
history.push(defaultAuthParams.afterLoginUrl);
return Promise.resolve();
},
[history]
);
return authProvider ? login : loginWithoutProvider;
}; |
That's by design: when a user is logged out bu a 403 response from the server and logs in again, they want to go back to the page they were visiting before. That means we must distinguish between an automated logout caused by a 403 (which should remember the last page) and a manual logout caused by a click on the "Logout" button (which should not remember the last page). |
You can see this in the demo.
1.- Login
2.- Browse to any view other than the Dashboard.
3.- Log out.
4.- Log in again.
Result: you get redirected to the latest view you visited.
Expected: You should be redirected to the Dashboard.
Changing the
Login
component doesn't seem to work:The text was updated successfully, but these errors were encountered: