fix: 修复登录后跳转的问题 (#7585)

* fix: 修复登录后跳转的问题


Co-authored-by: CaptainB <bin@fit2cloud.com>
This commit is contained in:
metersphere-bot 2021-11-08 11:11:59 +08:00 committed by GitHub
parent 723b8b745a
commit ac7aab1d23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -58,10 +58,13 @@ VueRouter.prototype.push = function push(location) {
// 登入后跳转至原路径
function redirectLoginPath(originPath) {
let redirectUrl = sessionStorage.getItem('redirectUrl');
let redirectUrl = '';
let loginSuccess = sessionStorage.getItem('loginSuccess');
sessionStorage.setItem('redirectUrl', originPath);
if (getCurrentUserId() !== sessionStorage.getItem('lastUser')) {
if (getCurrentUserId() === sessionStorage.getItem('lastUser')) {
redirectUrl = sessionStorage.getItem('redirectUrl');
}
if (!redirectUrl) {
if (hasPermissions('PROJECT_USER:READ', 'PROJECT_ENVIRONMENT:READ', 'PROJECT_OPERATING_LOG:READ', 'PROJECT_FILE:READ+JAR', 'PROJECT_FILE:READ+FILE', 'PROJECT_CUSTOM_CODE:READ')) {
redirectUrl = '/project/home';
} else if (hasPermissions('WORKSPACE_SERVICE:READ', 'WORKSPACE_MESSAGE:READ', 'WORKSPACE_USER:READ', 'WORKSPACE_PROJECT_MANAGER:READ', 'WORKSPACE_PROJECT_ENVIRONMENT:READ', 'WORKSPACE_OPERATING_LOG:READ', 'WORKSPACE_TEMPLATE:READ')) {
@ -72,11 +75,13 @@ function redirectLoginPath(originPath) {
redirectUrl = '/';
}
}
if (redirectUrl && loginSuccess) {
sessionStorage.removeItem('loginSuccess');
router.push(redirectUrl);
}
sessionStorage.setItem('lastUser', getCurrentUserId());
sessionStorage.setItem('redirectUrl', originPath);
sessionStorage.removeItem('loginSuccess');
}