增加 权限验证 util
This commit is contained in:
parent
989382e0e0
commit
16232dbfa1
19
src/utils/valid-perm.js
Normal file
19
src/utils/valid-perm.js
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
|
||||
/**
|
||||
* @description: 验证用户是否有权限使用api
|
||||
* @param {Array} perms 用户拥有的权限组
|
||||
* @param {Array} allowedPerm API需要的权限组
|
||||
* @return: Boolean 是否拥有权限
|
||||
*/
|
||||
|
||||
export default function(perms, allowedPerm) {
|
||||
let hasPerm = false;
|
||||
for (let i = 0; i < valid.length; i++) {
|
||||
if(perms.includes(allowedPerm[i])){
|
||||
hasPerm = true
|
||||
break
|
||||
}
|
||||
}
|
||||
return hasPerm
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user