MCPcopy Index your code
hub / github.com/coder/coder / userByName

Method userByName

coderd/users.go:760–775  ·  view source on GitHub ↗

Returns the parameterized user requested. All validation is completed in the middleware for this route. @Summary Get user by name @ID get-user-by-name @Security CoderSessionToken @Produce json @Tags Users @Param user path string true "User ID, username, or me" @Success 200 {object} codersdk.User @R

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

Source from the content-addressed store, hash-verified

758// @Success 200 {object} codersdk.User
759// @Router /api/v2/users/{user} [get]
760func (api *API) userByName(rw http.ResponseWriter, r *http.Request) {
761 ctx := r.Context()
762 user := httpmw.UserParam(r)
763 organizationIDs, err := userOrganizationIDs(ctx, api, user)
764 if err != nil {
765 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
766 Message: "Internal error fetching user's organizations.",
767 Detail: err.Error(),
768 })
769 return
770 }
771
772 sdkUser := db2sdk.User(user, organizationIDs)
773 api.enrichUserAISeat(ctx, &sdkUser)
774 httpapi.Write(ctx, rw, http.StatusOK, sdkUser)
775}
776
777// Returns recent build parameters for the signed-in user.
778//

Callers

nothing calls this directly

Calls 7

enrichUserAISeatMethod · 0.95
UserParamFunction · 0.92
WriteFunction · 0.92
UserFunction · 0.92
userOrganizationIDsFunction · 0.85
ContextMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected