Commit 10ceb282 by 展昭
parents af812148 2087a7e9
Showing with 10 additions and 3 deletions
...@@ -67,8 +67,9 @@ router.beforeEach((to, from, next) => { ...@@ -67,8 +67,9 @@ router.beforeEach((to, from, next) => {
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
const authcode = to.query.authCode || to.query.authcode; const authcode = to.query.authCode || to.query.authcode;
const appid = to.query.appId || to.query.appid; const appid = to.query.appId || to.query.appid;
const userId = to.query.userid || to.query.userId||0;
if (!!authcode && !!appid) { if (!!authcode && !!appid) {
localStorage.setItem('appid', appid);
var toPath = to.path || "/"; var toPath = to.path || "/";
for (let key in to.query) { for (let key in to.query) {
if (key == 'authcode') { if (key == 'authcode') {
...@@ -77,16 +78,22 @@ router.beforeEach((to, from, next) => { ...@@ -77,16 +78,22 @@ router.beforeEach((to, from, next) => {
toPath += toPath.indexOf("?") > -1 ? "&" : "?"; toPath += toPath.indexOf("?") > -1 ? "&" : "?";
toPath += `${key}=${to.query[key]}`; toPath += `${key}=${to.query[key]}`;
} }
const storeAppId = localStorage.getItem('appid');
store.dispatch("getOidcUser").then(oidcUser => { store.dispatch("getOidcUser").then(oidcUser => {
if (oidcUser) { if (oidcUser) {
if(storeAppId!= appid){
localStorage.setItem('appid',appid);
setAutoLogin({ autoCode: authcode, redirectPath: toPath })
store.dispatch("signOutOidc")
}else{
//如果登录用户与当前登录用户不匹配,则保存登录参数,退出 //如果登录用户与当前登录用户不匹配,则保存登录参数,退出
if (oidcUser.profile.sub != userId) { if (userId > 0 && oidcUser.profile.sub != userId) {
setAutoLogin({ autoCode: authcode, redirectPath: toPath }) setAutoLogin({ autoCode: authcode, redirectPath: toPath })
store.dispatch("signOutOidc") store.dispatch("signOutOidc")
} else { } else {
next() next()
} }
}
} else { } else {
autoLogin({ autoCode: authcode, redirectPath: toPath }) autoLogin({ autoCode: authcode, redirectPath: toPath })
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment