Fix user deletion handler

This commit is contained in:
2024-11-30 00:12:14 +01:00
parent 2a53be5a6e
commit 8bed3614ee

View File

@@ -1,7 +1,6 @@
package handlers package handlers
import ( import (
"database/sql"
"encoding/json" "encoding/json"
"net/http" "net/http"
@@ -155,18 +154,6 @@ func (h *Handler) DeleteAccount() http.HandlerFunc {
} }
} }
// Start transaction for consistent deletion
tx, err := h.DB.Begin()
if err != nil {
http.Error(w, "Failed to start transaction", http.StatusInternalServerError)
return
}
defer func() {
if err := tx.Rollback(); err != nil && err != sql.ErrTxDone {
http.Error(w, "Failed to rollback transaction", http.StatusInternalServerError)
}
}()
// Get user's workspaces for cleanup // Get user's workspaces for cleanup
workspaces, err := h.DB.GetWorkspacesByUserID(ctx.UserID) workspaces, err := h.DB.GetWorkspacesByUserID(ctx.UserID)
if err != nil { if err != nil {
@@ -188,11 +175,6 @@ func (h *Handler) DeleteAccount() http.HandlerFunc {
return return
} }
if err := tx.Commit(); err != nil {
http.Error(w, "Failed to commit transaction", http.StatusInternalServerError)
return
}
respondJSON(w, map[string]string{"message": "Account deleted successfully"}) respondJSON(w, map[string]string{"message": "Account deleted successfully"})
} }
} }