mirror of
https://github.com/AlistGo/alist.git
synced 2025-11-25 03:15:10 +08:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user