fix permission bug

This commit is contained in:
Pan 2017-05-11 16:52:38 +08:00
parent cab7d44771
commit b8068a4896
3 changed files with 8 additions and 4 deletions

View File

@ -48,7 +48,7 @@ router.beforeEach((to, from, next) => {
if (to.path === '/login') { if (to.path === '/login') {
next({ path: '/' }); next({ path: '/' });
} else { } else {
if (to.meta && to.meta.role) { if (to.meta && to.meta.role && store.getters.uid) {
if (hasPermission(store.getters.roles, to.meta.role)) { if (hasPermission(store.getters.roles, to.meta.role)) {
next(); next();
} else { } else {

View File

@ -4,14 +4,16 @@ const userMap = {
token: 'admin', token: 'admin',
introduction: '我是超级管理员', introduction: '我是超级管理员',
avatar: 'https://wdl.wallstreetcn.com/48a3e1e0-ea2c-4a4e-9928-247645e3428b', avatar: 'https://wdl.wallstreetcn.com/48a3e1e0-ea2c-4a4e-9928-247645e3428b',
name: '超级管理员小潘' name: '超级管理员小潘',
uid: '001'
}, },
editor: { editor: {
role: ['editor'], role: ['editor'],
token: 'editor', token: 'editor',
introduction: '我是编辑', introduction: '我是编辑',
avatar: 'https://wdl.wallstreetcn.com/48a3e1e0-ea2c-4a4e-9928-247645e3428b', avatar: 'https://wdl.wallstreetcn.com/48a3e1e0-ea2c-4a4e-9928-247645e3428b',
name: '普通编辑小张' name: '普通编辑小张',
uid: '002'
}, },
developer: { developer: {
@ -19,7 +21,8 @@ const userMap = {
token: 'develop', token: 'develop',
introduction: '我是开发', introduction: '我是开发',
avatar: 'https://wdl.wallstreetcn.com/48a3e1e0-ea2c-4a4e-9928-247645e3428b', avatar: 'https://wdl.wallstreetcn.com/48a3e1e0-ea2c-4a4e-9928-247645e3428b',
name: '工程师小王' name: '工程师小王',
uid: '003'
} }
} }

View File

@ -87,6 +87,7 @@ const user = {
commit('SET_ROLES', data.role); commit('SET_ROLES', data.role);
commit('SET_NAME', data.name); commit('SET_NAME', data.name);
commit('SET_AVATAR', data.avatar); commit('SET_AVATAR', data.avatar);
commit('SET_UID', data.uid);
commit('SET_INTRODUCTION', data.introduction); commit('SET_INTRODUCTION', data.introduction);
resolve(response); resolve(response);
}).catch(error => { }).catch(error => {