Use only after requireAuthentication, so that there is a valid user
(w http.ResponseWriter, r *http.Request)
| 72 | |
| 73 | // Use only after requireAuthentication, so that there is a valid user |
| 74 | func (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 | |
| 95 | func (a *API) getAdminParams(r *http.Request) (*AdminUserParams, error) { |
| 96 | params := &AdminUserParams{} |
nothing calls this directly
no test coverage detected