(w http.ResponseWriter, r *http.Request)
| 576 | } |
| 577 | |
| 578 | func (a *API) adminUserDeleteFactor(w http.ResponseWriter, r *http.Request) error { |
| 579 | ctx := r.Context() |
| 580 | config := a.config |
| 581 | user := getUser(ctx) |
| 582 | factor := getFactor(ctx) |
| 583 | db := a.db.WithContext(ctx) |
| 584 | |
| 585 | err := db.Transaction(func(tx *storage.Connection) error { |
| 586 | if terr := models.NewAuditLogEntry(config.AuditLog, r, tx, user, models.DeleteFactorAction, utilities.GetIPAddress(r), map[string]interface{}{ |
| 587 | "user_id": user.ID, |
| 588 | "factor_id": factor.ID, |
| 589 | }); terr != nil { |
| 590 | return terr |
| 591 | } |
| 592 | if terr := tx.Destroy(factor); terr != nil { |
| 593 | return apierrors.NewInternalServerError("Database error deleting factor").WithInternalError(terr) |
| 594 | } |
| 595 | return nil |
| 596 | }) |
| 597 | if err != nil { |
| 598 | return err |
| 599 | } |
| 600 | return sendJSON(w, http.StatusOK, factor) |
| 601 | } |
| 602 | |
| 603 | func (a *API) adminUserGetFactors(w http.ResponseWriter, r *http.Request) error { |
| 604 | ctx := r.Context() |
nothing calls this directly
no test coverage detected