feat(user-db): enhance user management with role-based queries (allow-edit-role-guest) (#9234)

- Add `GetUsersByRole` function to fetch users based on their roles.
- Extend `UpdateUserBasePathPrefix` to accept optional user lists.
- Ensure path cleaning in `UpdateUserBasePathPrefix` for consistency.
- Integrate guest role fetching in `auth.go` middleware.
- Utilize `GetUsersByRole` in `role.go` for base path modifications.
- Remove redundant line in `role.go` role modification logic.
This commit is contained in:
千石
2025-07-30 13:15:35 +08:00
committed by GitHub
parent 74332e91fb
commit 280960ce3e
3 changed files with 42 additions and 9 deletions

View File

@@ -41,6 +41,15 @@ func Auth(c *gin.Context) {
c.Abort()
return
}
if len(guest.Role) > 0 {
roles, err := op.GetRolesByUserID(guest.ID)
if err != nil {
common.ErrorStrResp(c, fmt.Sprintf("Fail to load guest roles: %v", err), 500)
c.Abort()
return
}
guest.RolesDetail = roles
}
c.Set("user", guest)
log.Debugf("use empty token: %+v", guest)
c.Next()