Skip to content

Commit

Permalink
resolved conversations
Browse files Browse the repository at this point in the history
  • Loading branch information
karjo24 committed Nov 29, 2024
1 parent a62d6f7 commit 869703e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions api/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,18 @@ func (r usersRoutes) prepareUserSearch(c *gin.Context) (users []model.User, err
})
return nil, errors.New("query too short (minimum length is 3)")
}
role, err := strconv.ParseUint(rQ, 10, 64)
if err != nil && rQ != "" && rQ != "-1" {
tools.RenderErrorPage(c, http.StatusBadRequest, "invalid role")
return nil, err
}
if rQ == "" || rQ == "-1" {
users, err = r.UsersDao.SearchUser(q)
} else {
role, err := strconv.ParseUint(rQ, 10, 64)
if err != nil {
_ = c.Error(tools.RequestError{
Status: http.StatusBadRequest,
CustomMessage: "could not parse role",
Err: err,
})
return nil, err
}
users, err = r.UsersDao.SearchUserWithRole(q, role)
}
if err != nil && err != gorm.ErrRecordNotFound {
Expand Down

0 comments on commit 869703e

Please sign in to comment.