MCPcopy Create free account
hub / github.com/netlify/gotrue / adminUserDelete

Method adminUserDelete

api/admin.go:226–250  ·  view source on GitHub ↗

adminUserDelete delete a user

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

Source from the content-addressed store, hash-verified

224
225// adminUserDelete delete a user
226func (a *API) adminUserDelete(w http.ResponseWriter, r *http.Request) error {
227 ctx := r.Context()
228 user := getUser(ctx)
229 instanceID := getInstanceID(ctx)
230 adminUser := getAdminUser(ctx)
231
232 err := a.db.Transaction(func(tx *storage.Connection) error {
233 if terr := models.NewAuditLogEntry(tx, instanceID, adminUser, models.UserDeletedAction, map[string]interface{}{
234 "user_id": user.ID,
235 "user_email": user.Email,
236 }); terr != nil {
237 return internalServerError("Error recording audit log entry").WithInternalError(terr)
238 }
239
240 if terr := tx.Destroy(user); terr != nil {
241 return internalServerError("Database error deleting user").WithInternalError(terr)
242 }
243 return nil
244 })
245 if err != nil {
246 return err
247 }
248
249 return sendJSON(w, http.StatusOK, map[string]interface{}{})
250}

Callers

nothing calls this directly

Calls 8

NewAuditLogEntryFunction · 0.92
getUserFunction · 0.85
getInstanceIDFunction · 0.85
getAdminUserFunction · 0.85
internalServerErrorFunction · 0.85
sendJSONFunction · 0.85
TransactionMethod · 0.80
WithInternalErrorMethod · 0.45

Tested by

no test coverage detected