Giter Club home page Giter Club logo

Comments (1)

zuihou avatar zuihou commented on May 22, 2024 1

报错原因:

  1. 提示的执行方法[page]需要[hasPermit('station123:view')]权限是由于后端UriSecurityPreAuthAspect类检测到page方法需要station123:view权限, 而当前用户没有该权限.
  2. 没有显示新增、修改等按钮是由于前端自定义指令v-has-permission 检测到当前用户没有station123:add 等权限.

解决方案:

  1. 前往 “菜单管理” 页面, 选择对应的菜单, 然后在该菜单下配置资源权限.
    image
    ps: 为了演示我把StationController类的注解改成了@PreAuth(replace = "station123:"), 所以提示没有station123:view 权限. 上图中,我这里配置的都是 station:* 权限, 所以会提示没有权限

  2. 点击上图的新增,编码输入station123:view , 名称输入查询.

  3. 前往“角色管理”, 将新建的权限编码station123:view分配给超管.

  4. 切换回 “岗位管理” 刷新页面, 可能访问后端数据

  5. 但此时页面上还是没有 新增、修改等按钮, 是因为前端将用户等权限缓存到了LocalStorage,所以需要用户退出后,重新登录.

后端URI权限原理

通过 @PreAuth 注解拦截Controller 类方法, 判断当前请求头token中封装的用户,是否拥有权限.
代码参考:

  1. UriSecurityPreAuthAspect //拦截PreAuth注解,并解析注解上标记的资源编码
  2. VerifyAuthFunction //远程调用接口,获取当前用户的权限, 并判断返回是否拥有指定权限
  3. OauthUserController#getById // 被调用方, 执行具体的查询逻辑, 查询指定用户拥有的全部权限等数据

前端按钮权限原理

通过按钮上加自定义指令v-has-permissionv-has-any-permissionv-has-no-permission 控制按钮的权限.
代码参考:

  1. permissionDirect.js

from lamp-cloud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.