MCPcopy Create free account
hub / github.com/netlify/gotrue / adminUsers

Method adminUsers

api/admin.go:54–81  ·  view source on GitHub ↗

adminUsers responds with a list of all users in a given audience

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

52
53// adminUsers responds with a list of all users in a given audience
54func (a *API) adminUsers(w http.ResponseWriter, r *http.Request) error {
55 ctx := r.Context()
56 instanceID := getInstanceID(ctx)
57 aud := a.requestAud(ctx, r)
58
59 pageParams, err := paginate(r)
60 if err != nil {
61 return badRequestError("Bad Pagination Parameters: %v", err)
62 }
63
64 sortParams, err := sort(r, map[string]bool{models.CreatedAt: true}, []models.SortField{models.SortField{Name: models.CreatedAt, Dir: models.Descending}})
65 if err != nil {
66 return badRequestError("Bad Sort Parameters: %v", err)
67 }
68
69 filter := r.URL.Query().Get("filter")
70
71 users, err := models.FindUsersInAudience(a.db, instanceID, aud, pageParams, sortParams, filter)
72 if err != nil {
73 return internalServerError("Database error finding users").WithInternalError(err)
74 }
75 addPaginationHeaders(w, r, pageParams)
76
77 return sendJSON(w, http.StatusOK, map[string]interface{}{
78 "users": users,
79 "aud": aud,
80 })
81}
82
83// adminUserGet returns information about a single user
84func (a *API) adminUserGet(w http.ResponseWriter, r *http.Request) error {

Callers

nothing calls this directly

Calls 11

requestAudMethod · 0.95
FindUsersInAudienceFunction · 0.92
getInstanceIDFunction · 0.85
paginateFunction · 0.85
badRequestErrorFunction · 0.85
sortFunction · 0.85
internalServerErrorFunction · 0.85
addPaginationHeadersFunction · 0.85
sendJSONFunction · 0.85
GetMethod · 0.80
WithInternalErrorMethod · 0.45

Tested by

no test coverage detected