gin-admin icon indicating copy to clipboard operation
gin-admin copied to clipboard

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

Open thum123 opened this issue 2 years ago • 1 comments

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

thum123 avatar Mar 23 '22 10:03 thum123

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

thum123 avatar Mar 23 '22 10:03 thum123

1

thum123 avatar Oct 09 '22 07:10 thum123