Commit 2d337ea3 by 展昭

删除 router中的mgr逻辑

parent 782460b8
Showing with 1 additions and 53 deletions
...@@ -4,7 +4,7 @@ import moreRouters from './more-router.js' ...@@ -4,7 +4,7 @@ import moreRouters from './more-router.js'
import billRouters from './bill-router.js' import billRouters from './bill-router.js'
import { vuexOidcCreateRouterMiddleware } from 'vuex-oidc' import { vuexOidcCreateRouterMiddleware } from 'vuex-oidc'
import store from '../store' import store from '../store'
import Mgr from "../assets/js/SecurityService"
Vue.use(VueRouter) Vue.use(VueRouter)
...@@ -30,58 +30,6 @@ const router = new VueRouter({ ...@@ -30,58 +30,6 @@ const router = new VueRouter({
} }
}) })
const mgr = new Mgr();
function loginByAuthcode(authCode) {
let loginArgs = { extraQueryParams: { authcode: authCode } };
mgr.signIn(loginArgs);
}
function autoLogin(comid, authcode, next) {
localStorage.setItem("comid", comid);
mgr.getUser().then(user => {
if (user == null) {
loginByAuthcode(authcode);
} else {
let companyId = localStorage.getItem("companyId");
if (comid != companyId) {
//如果已经登录,则先退出
localStorage.setItem("authcode", authcode);
mgr.signOut();
} else {
next();
}
}
})
}
router.beforeEach(vuexOidcCreateRouterMiddleware(store)); router.beforeEach(vuexOidcCreateRouterMiddleware(store));
router.beforeEach((to, from, next) => {
let authcode = localStorage.getItem("authcode")
if (authcode) {
localStorage.removeItem("authcode");
loginByAuthcode(authcode)
}
else {
authcode = to.query.authcode;
const comid = to.query.comId || to.query.comid;
if (comid && authcode) {
localStorage.setItem("autoCallback", to.path);
autoLogin(comid, authcode, next);
} else {
mgr.getUser().then(user => {
if (user == null) {
mgr.signIn();
} else {
next()
}
});
}
}
});
export default router export default router
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