Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

操作权限校验判断失败 #319

Open
1141195251 opened this issue Sep 22, 2022 · 0 comments
Open

操作权限校验判断失败 #319

1141195251 opened this issue Sep 22, 2022 · 0 comments

Comments

@1141195251
Copy link

1141195251 commented Sep 22, 2022

/**
 * 操作权限校验
 * @param authConfig
 * @param permission
 * @param role
 * @param permissions
 * @param roles
 * @returns {boolean}
 */
const auth = function(authConfig, permission, role, permissions, roles) {
  // authConfig的模板 deleteRecord: {
  //                                  check: 'delete',
  //                                  type: 'role'
  //                               }
  const {check, type} = authConfig
  if (check && typeof check === 'function') {
    return check.apply(this, [permission, role, permissions, roles])
  }
  if (type === 'permission') {
    return checkFromPermission(check, permission)
  } else if (type === 'role') { 
    // 以上面authConfig传入时,role传进的参数一直为空数组role=[]
    return checkFromRoles(check, role)  // role参数改为roles,操作校验就成功了
  } else {
    return checkFromPermission(check, permission) || checkFromRoles(check, role) // role=>roles
  }
}

https://github.com/iczer/vue-antd-admin/blob/basic/src/plugins/authority-plugin.js

[上面失败的情况,是在vuex持有多角色时出现的,不知道单角色的环境下会不会发生]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant