MCPcopy Create free account
hub / github.com/supabase/auth / loadUser

Method loadUser

internal/api/admin.go:51–71  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

49}
50
51func (a *API) loadUser(w http.ResponseWriter, r *http.Request) (context.Context, error) {
52 ctx := r.Context()
53 db := a.db.WithContext(ctx)
54
55 userID, err := uuid.FromString(chi.URLParam(r, "user_id"))
56 if err != nil {
57 return nil, apierrors.NewNotFoundError(apierrors.ErrorCodeValidationFailed, "user_id must be an UUID")
58 }
59
60 observability.LogEntrySetField(r, "user_id", userID)
61
62 u, err := models.FindUserByID(db, userID)
63 if err != nil {
64 if models.IsNotFoundError(err) {
65 return nil, apierrors.NewNotFoundError(apierrors.ErrorCodeUserNotFound, "User not found")
66 }
67 return nil, apierrors.NewInternalServerError("Database error loading user").WithInternalError(err)
68 }
69
70 return withUser(ctx, u), nil
71}
72
73// Use only after requireAuthentication, so that there is a valid user
74func (a *API) loadFactor(w http.ResponseWriter, r *http.Request) (context.Context, error) {

Callers

nothing calls this directly

Calls 8

NewNotFoundErrorFunction · 0.92
LogEntrySetFieldFunction · 0.92
FindUserByIDFunction · 0.92
IsNotFoundErrorFunction · 0.92
NewInternalServerErrorFunction · 0.92
withUserFunction · 0.85
WithContextMethod · 0.80
WithInternalErrorMethod · 0.45

Tested by

no test coverage detected