feat: get user api return roles and permissions (#929)

This commit is contained in:
Resulte Lee
2022-07-30 17:31:56 +08:00
committed by GitHub
parent 1c72f5300c
commit 155660b0d7
9 changed files with 62 additions and 0 deletions

View File

@ -121,3 +121,13 @@ func DeleteRole(role *Role) bool {
func (role *Role) GetId() string {
return fmt.Sprintf("%s/%s", role.Owner, role.Name)
}
func GetRolesByUser(userId string) []*Role {
roles := []*Role{}
err := adapter.Engine.Where("users like ?", "%"+userId+"%").Find(&roles)
if err != nil {
panic(err)
}
return roles
}