Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: add count endpoint for users, enabling better pagination #4848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Nov 8, 2022
Merged
Prev Previous commit
Next Next commit
More authorization tweaks
  • Loading branch information
presleyp committed Nov 4, 2022
commit ca4a82f3d963b364f95992fbd15656da518d1734
11 changes: 10 additions & 1 deletion coderd/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,20 @@ func (api *API) userCount(rw http.ResponseWriter, r *http.Request) {
return
}

sqlFilter, err := api.HTTPAuth.AuthorizeSQLFilter(r, rbac.ActionRead, rbac.ResourceUser.Type)
if err != nil {
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
Message: "Internal error preparing sql filter.",
Detail: err.Error(),
})
return
}

count, err := api.Database.GetAuthorizedUserCount(ctx, database.GetFilteredUserCountParams{
Search: params.Search,
Status: params.Status,
RbacRole: params.RbacRole,
})
}, sqlFilter)
if err != nil {
httpapi.InternalServerError(rw, err)
return
Expand Down