MCPcopy Index your code
hub / github.com/supabase/auth / loadFactor

Method loadFactor

internal/api/admin.go:74–93  ·  view source on GitHub ↗

Use only after requireAuthentication, so that there is a valid user

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

Source from the content-addressed store, hash-verified

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) {
75 ctx := r.Context()
76 db := a.db.WithContext(ctx)
77 user := getUser(ctx)
78 factorID, err := uuid.FromString(chi.URLParam(r, "factor_id"))
79 if err != nil {
80 return nil, apierrors.NewNotFoundError(apierrors.ErrorCodeValidationFailed, "factor_id must be an UUID")
81 }
82
83 observability.LogEntrySetField(r, "factor_id", factorID)
84
85 factor, err := user.FindOwnedFactorByID(db, factorID)
86 if err != nil {
87 if models.IsNotFoundError(err) {
88 return nil, apierrors.NewNotFoundError(apierrors.ErrorCodeMFAFactorNotFound, "Factor not found")
89 }
90 return nil, apierrors.NewInternalServerError("Database error loading factor").WithInternalError(err)
91 }
92 return withFactor(ctx, factor), nil
93}
94
95func (a *API) getAdminParams(r *http.Request) (*AdminUserParams, error) {
96 params := &AdminUserParams{}

Callers

nothing calls this directly

Calls 9

NewNotFoundErrorFunction · 0.92
LogEntrySetFieldFunction · 0.92
IsNotFoundErrorFunction · 0.92
NewInternalServerErrorFunction · 0.92
getUserFunction · 0.85
withFactorFunction · 0.85
WithContextMethod · 0.80
FindOwnedFactorByIDMethod · 0.80
WithInternalErrorMethod · 0.45

Tested by

no test coverage detected