mirror of
http://git.mhez-qa.uplus.co.kr/hubez/hubez-admin.git
synced 2025-12-07 01:17:51 +09:00
router Store Login Path 확인 설정
This commit is contained in:
@@ -3,29 +3,31 @@ const state = {
|
|||||||
isLogin: false,
|
isLogin: false,
|
||||||
isErrorPage: false,
|
isErrorPage: false,
|
||||||
isAuthChk: false,
|
isAuthChk: false,
|
||||||
userId:null,
|
userId: null,
|
||||||
userNm:null,
|
userNm: null,
|
||||||
pwd: null,
|
pwd: null,
|
||||||
rootUrl: null,
|
rootUrl: null,
|
||||||
menuUrls: [],
|
menuUrls: [],
|
||||||
authToken: null,
|
authToken: null,
|
||||||
beforeUrl: null,
|
beforeUrl: null,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
loginPathUrl: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const getters = {
|
const getters = {
|
||||||
getToken: state => state.token,
|
getToken: (state) => state.token,
|
||||||
isLogin: state => state.isLogin,
|
isLogin: (state) => state.isLogin,
|
||||||
isErrorPage: state => state.isErrorPage,
|
isErrorPage: (state) => state.isErrorPage,
|
||||||
isAuthChk: state => state.isAuthChk,
|
isAuthChk: (state) => state.isAuthChk,
|
||||||
userId: state => state.userId,
|
userId: (state) => state.userId,
|
||||||
userNm: state => state.userNm,
|
userNm: (state) => state.userNm,
|
||||||
getPwd: state => state.pwd,
|
getPwd: (state) => state.pwd,
|
||||||
getRootUrl: state => state.rootUrl,
|
getRootUrl: (state) => state.rootUrl,
|
||||||
getMenuUrls: state => state.menuUrls,
|
getMenuUrls: (state) => state.menuUrls,
|
||||||
getAuthToken: state => state.authToken,
|
getAuthToken: (state) => state.authToken,
|
||||||
getBeforeUrl: state => state.beforeUrl,
|
getBeforeUrl: (state) => state.beforeUrl,
|
||||||
isLoading: state => state.isLoading,
|
isLoading: (state) => state.isLoading,
|
||||||
|
getLoginPathUrl: (state) => state.loginPathUrl,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
@@ -70,16 +72,18 @@ const mutations = {
|
|||||||
},
|
},
|
||||||
isLoading: (state, value) => {
|
isLoading: (state, value) => {
|
||||||
state.isLoading = value;
|
state.isLoading = value;
|
||||||
}
|
},
|
||||||
|
setLoginPathUrl: (state, value) => {
|
||||||
|
state.loginPathUrl = value;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const actions = {
|
const actions = {};
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state,
|
state,
|
||||||
getters,
|
getters,
|
||||||
mutations,
|
mutations,
|
||||||
actions
|
actions,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ const router = new Router({
|
|||||||
...profileRoutes,
|
...profileRoutes,
|
||||||
...mntrngRoutes,
|
...mntrngRoutes,
|
||||||
...riskmgtRoutes,
|
...riskmgtRoutes,
|
||||||
...monthRoutes,
|
|
||||||
...homeMgtRoutes,
|
...homeMgtRoutes,
|
||||||
|
...monthRoutes,
|
||||||
//{path: '*', name: 'error404'}
|
//{path: '*', name: 'error404'}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -66,11 +66,8 @@ const router = new Router({
|
|||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
const isPublic = to.matched.some((record) => record.meta.public);
|
const isPublic = to.matched.some((record) => record.meta.public);
|
||||||
const loggedIn = !!tokenSvc.getToken();
|
const loggedIn = !!tokenSvc.getToken();
|
||||||
console.log(isPublic);
|
|
||||||
console.log(loggedIn);
|
|
||||||
console.log(to);
|
|
||||||
if (!isPublic && !loggedIn) {
|
if (!isPublic && !loggedIn) {
|
||||||
console.log('1');
|
store.commit('login/setLoginPathUrl', 1);
|
||||||
return next('/login');
|
return next('/login');
|
||||||
} else {
|
} else {
|
||||||
var nextUrl = to.fullPath;
|
var nextUrl = to.fullPath;
|
||||||
@@ -201,7 +198,7 @@ router.beforeEach((to, from, next) => {
|
|||||||
fromUrl == '/view/login/resetPassword' ||
|
fromUrl == '/view/login/resetPassword' ||
|
||||||
fromUrl == '/view/login/updatePassword'
|
fromUrl == '/view/login/updatePassword'
|
||||||
) {
|
) {
|
||||||
console.log('2');
|
store.commit('login/setLoginPathUrl', 2);
|
||||||
return next('/login');
|
return next('/login');
|
||||||
}
|
}
|
||||||
// store.commit("login/isErrorPage", true);
|
// store.commit("login/isErrorPage", true);
|
||||||
@@ -214,7 +211,7 @@ router.beforeEach((to, from, next) => {
|
|||||||
nextUrl == '/view/login/updatePassword'
|
nextUrl == '/view/login/updatePassword'
|
||||||
) {
|
) {
|
||||||
if (fromUrl != '/login') {
|
if (fromUrl != '/login') {
|
||||||
console.log('3');
|
store.commit('login/setLoginPathUrl', 3);
|
||||||
return next('/login');
|
return next('/login');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -222,7 +219,7 @@ router.beforeEach((to, from, next) => {
|
|||||||
if (nextUrl == '/') {
|
if (nextUrl == '/') {
|
||||||
const rootUrl = store.getters['login/getRootUrl'];
|
const rootUrl = store.getters['login/getRootUrl'];
|
||||||
if (rootUrl == null) {
|
if (rootUrl == null) {
|
||||||
console.log('4');
|
store.commit('login/setLoginPathUrl', 4);
|
||||||
return next('/login');
|
return next('/login');
|
||||||
}
|
}
|
||||||
return next(rootUrl);
|
return next(rootUrl);
|
||||||
@@ -231,7 +228,7 @@ router.beforeEach((to, from, next) => {
|
|||||||
if (nextUrl == '/login' && loggedIn) {
|
if (nextUrl == '/login' && loggedIn) {
|
||||||
const rootUrl = store.getters['login/getRootUrl'];
|
const rootUrl = store.getters['login/getRootUrl'];
|
||||||
if (rootUrl == null) {
|
if (rootUrl == null) {
|
||||||
console.log('5');
|
store.commit('login/setLoginPathUrl', 5);
|
||||||
return next('/login');
|
return next('/login');
|
||||||
}
|
}
|
||||||
return next(rootUrl);
|
return next(rootUrl);
|
||||||
|
|||||||
Reference in New Issue
Block a user