Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
op-web-service
Project
Project
Details
Activity
Releases
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
bp
op-web-service
Commits
d9329b8f
Commit
d9329b8f
authored
Aug 17, 2021
by
liwenhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:login permission
parent
949f0a56
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
34 deletions
+16
-34
App.vue
src/App.vue
+4
-24
RoleList.vue
src/components/Roles/RoleList.vue
+1
-0
main.js
src/main.js
+9
-9
user.js
src/store/modules/user.js
+2
-1
No files found.
src/App.vue
View file @
d9329b8f
...
@@ -10,36 +10,16 @@
...
@@ -10,36 +10,16 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
{
fetchCurrentUser
}
from
"./service/user"
;
import
{
getCookie
,
redirectToLogin
}
from
"@/utils/util"
;
import
{
getCookie
,
redirectToLogin
}
from
"@/utils/util"
;
export
default
{
export
default
{
async
mounted
()
{
async
mounted
()
{
if
(
this
.
$store
.
state
.
permissions
&&
this
.
$store
.
state
.
userInfo
)
return
;
if
(
this
.
$store
.
state
.
permissions
&&
this
.
$store
.
state
.
userInfo
)
return
;
if
(
!
getCookie
(
'username'
)
)
{
if
(
!
getCookie
(
'username'
)
&&
window
.
location
.
pathname
!=
'/op/login'
)
{
this
.
$message
(
'请先登录'
);
this
.
$message
(
'请先登录'
);
return
redirectToLogin
();
return
redirectToLogin
();
}
}
const
{
status
,
user
}
=
await
fetchCurrentUser
();
// let isDefault = window.localStorage.getItem('isDefault');
// if (isDefault == 2) return;
console
.
log
(
'status'
,
status
)
console
.
log
(
'user'
,
user
)
if
(
status
===
"success"
)
{
this
.
$store
.
commit
(
"updateUserInfo"
,
user
);
this
.
$store
.
dispatch
(
"updateUserPermission"
,
{
email
:
user
.
email
});
// 无奈之举,后期需要重构到提现管理中
this
.
$store
.
dispatch
(
"fetchPermission"
,
{
appId
:
"merchant-op-auditing"
,
});
}
else
{
return
redirectToLogin
();
}
},
},
computed
:
{
}
};
};
</
script
>
</
script
>
...
...
src/components/Roles/RoleList.vue
View file @
d9329b8f
...
@@ -155,6 +155,7 @@ export default {
...
@@ -155,6 +155,7 @@ export default {
let
appId
=
this
.
appId
||
""
;
let
appId
=
this
.
appId
||
""
;
const
modulePermissions
=
const
modulePermissions
=
this
.
$store
.
getters
.
moduleSubPermissions
(
rolePermissionId
,
appId
)
||
[];
this
.
$store
.
getters
.
moduleSubPermissions
(
rolePermissionId
,
appId
)
||
[];
console
.
log
(
'modulePermissions'
,
modulePermissions
)
return
new
Map
(
modulePermissions
.
map
((
ele
)
=>
[
ele
.
name
,
true
]));
return
new
Map
(
modulePermissions
.
map
((
ele
)
=>
[
ele
.
name
,
true
]));
},
},
},
},
...
...
src/main.js
View file @
d9329b8f
...
@@ -19,26 +19,26 @@ router.beforeResolve(async (to, from, next) => {
...
@@ -19,26 +19,26 @@ router.beforeResolve(async (to, from, next) => {
next
();
next
();
return
true
;
return
true
;
}
}
let
isDefault
=
window
.
localStorage
.
getItem
(
"isDefault"
);
if
(
!
store
.
state
.
permissions
)
{
if
(
!
store
.
state
.
permissions
&&
isDefault
==
1
)
{
const
{
status
,
user
}
=
await
fetchCurrentUser
();
const
{
status
,
user
}
=
await
fetchCurrentUser
();
if
(
status
===
"success"
)
{
if
(
status
===
"success"
)
{
store
.
commit
(
"updateUserInfo"
,
user
);
store
.
commit
(
"updateUserInfo"
,
user
);
console
.
log
(
"updateUserInfo====="
,
user
);
await
store
.
dispatch
(
"updateUserPermission"
,
{
email
:
user
.
email
});
await
store
.
dispatch
(
"updateUserPermission"
,
{
email
:
user
.
email
});
store
.
dispatch
(
"fetchPermission"
,
{
appId
:
"merchant-op-auditing"
,
});
}
else
{
}
else
{
redirectToLogin
();
redirectToLogin
();
return
ElMessage
(
"您没有权限"
);
return
ElMessage
(
"您没有权限"
);
}
}
}
}
// .......
// if (isDefault === "2") {
if
(
isDefault
===
"2"
)
{
// await store.dispatch("updateUserPermission", {
await
store
.
dispatch
(
"updateUserPermission"
,
{
// email: localStorage.getItem("_user_email")
email
:
localStorage
.
getItem
(
"_user_email"
)
// });
});
// }
}
if
(
!
checkPathAuth
(
to
.
path
))
{
if
(
!
checkPathAuth
(
to
.
path
))
{
redirectToLogin
();
redirectToLogin
();
...
...
src/store/modules/user.js
View file @
d9329b8f
...
@@ -32,6 +32,7 @@ export default {
...
@@ -32,6 +32,7 @@ export default {
async
fetchPermission
({
commit
},
{
email
,
appId
})
{
async
fetchPermission
({
commit
},
{
email
,
appId
})
{
if
(
appId
===
"merchant-op-auditing"
)
{
if
(
appId
===
"merchant-op-auditing"
)
{
const
permissions
=
await
getRolesForUser
(
email
);
const
permissions
=
await
getRolesForUser
(
email
);
console
.
log
(
'permissions'
,
permissions
)
if
(
!
permissions
)
{
if
(
!
permissions
)
{
return
;
return
;
}
}
...
...
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