-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
不同账号登入导致权限冲突问题 #11312
Comments
修改此处的逻辑即可: /**
* 退出登录,并且将当前的 url 保存
*/
const loginOut = async () => {
await outLogin();
const { search, pathname } = window.location;
const urlParams = new URL(window.location.href).searchParams;
/** 此方法会跳转到 redirect 参数所在的位置 */
const redirect = urlParams.get('redirect');
// Note: There may be security issues, please note
if (window.location.pathname !== '/user/login' && !redirect) {
history.replace({
pathname: '/user/login',
search: stringify({
redirect: pathname + search,
}),
});
}
}; |
或者修改此处的逻辑,文件在 page/User/Login/index.tsx const handleSubmit = async (values: API.LoginParams) => {
try {
// 登录
const msg = await login({ ...values, type });
if (msg.status === 'ok') {
const defaultLoginSuccessMessage = intl.formatMessage({
id: 'pages.login.success',
defaultMessage: '登录成功!',
});
message.success(defaultLoginSuccessMessage);
await fetchUserInfo();
const urlParams = new URL(window.location.href).searchParams;
// 删除代码
history.push(urlParams.get('redirect') || '/');
return;
}
console.log(msg);
// 如果失败去设置用户错误信息
setUserLoginState(msg);
} catch (error) {
const defaultLoginFailureMessage = intl.formatMessage({
id: 'pages.login.failure',
defaultMessage: '登录失败,请重试!',
});
console.log(error);
message.error(defaultLoginFailureMessage);
}
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使用一个账号打开拥有权限的页面后并登出,使用另一个账号登入时,网页会自动打开之前账号已经开打过的标签,这时如果正在登入的账号没有对应权限就会报错。
目前想到的是当登出时候移除开打的标签页,或者登入时不会自动打开之前登入账号的标签页。 但是不知道哪里去控制标签页的记录。或者提供下其他方法可以避免上面出现的权限问题吗。
The text was updated successfully, but these errors were encountered: