LyricTian / gin-admin

A lightweight, flexible, elegant and full-featured RBAC scaffolding based on GIN + GORM 2.0 + Casbin 2.0 + Wire DI.

Home Page:http://101.42.232.163:8040

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

给角色添加权限后,角色对应的用户的所有权限都没了提示no permission

thum123 opened this issue · comments

AddPermissionForUser这个方法添加的权限没有生效 @LyricTian

没有生效的原因应该是 a.Enforcer.DeleteRole(strconv.FormatUint(item.ID, 10))
这个把用户和角色的关系也删除了,导致权限判断的时候没有根据用户id找到对应的角色权限
应该使用 a.Enforcer.DeletePermissionsForUser(strconv.FormatUint(item.ID, 10))
这个只清除角色对应的权限

1