mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 16:04:23 +00:00
Fix user deletion handler
This commit is contained in:
@@ -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"})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user