Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
W
web-monitor
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
web-monitor
Commits
0fea37b6
Commit
0fea37b6
authored
May 02, 2018
by
Pan
Committed by
花裤衩
May 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf[permission]: add the verification of roles
parent
c3ee0047
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
permission.js
src/permission.js
+3
-3
user.js
src/store/modules/user.js
+6
-2
No files found.
src/permission.js
View file @
0fea37b6
...
...
@@ -16,10 +16,10 @@ router.beforeEach((to, from, next) => {
if
(
store
.
getters
.
roles
.
length
===
0
)
{
store
.
dispatch
(
'GetInfo'
).
then
(
res
=>
{
// 拉取用户信息
next
()
}).
catch
(()
=>
{
}).
catch
((
err
)
=>
{
store
.
dispatch
(
'FedLogOut'
).
then
(()
=>
{
Message
.
error
(
'验证失败,请重新登录
'
)
next
({
path
:
'/
login
'
})
Message
.
error
(
err
||
'Verification failed, please login again
'
)
next
({
path
:
'/'
})
})
})
}
else
{
...
...
src/store/modules/user.js
View file @
0fea37b6
...
...
@@ -44,8 +44,12 @@ const user = {
GetInfo
({
commit
,
state
})
{
return
new
Promise
((
resolve
,
reject
)
=>
{
getInfo
(
state
.
token
).
then
(
response
=>
{
const
data
=
response
.
data
commit
(
'SET_ROLES'
,
data
.
roles
)
const
data
=
response
if
(
data
.
roles
&&
data
.
roles
.
length
>
0
)
{
// 验证返回的roles是否是一个非空数组
commit
(
'SET_ROLES'
,
data
.
roles
)
}
else
{
reject
(
'getInfo: roles must be a non-null array !'
)
}
commit
(
'SET_NAME'
,
data
.
name
)
commit
(
'SET_AVATAR'
,
data
.
avatar
)
resolve
(
response
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment