From aebc012eef6d7f423609888db5750fcda2f36dfc Mon Sep 17 00:00:00 2001 From: mkelvers Date: Wed, 22 Apr 2026 21:43:33 +0200 Subject: [PATCH] fix: extract user ID from path correctly --- api/admin/handler.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/api/admin/handler.go b/api/admin/handler.go index 549d997..d987796 100644 --- a/api/admin/handler.go +++ b/api/admin/handler.go @@ -88,15 +88,14 @@ func (h *Handler) HandleAddUserForm(w http.ResponseWriter, r *http.Request) { func (h *Handler) HandleDeleteUserRouter(w http.ResponseWriter, r *http.Request) { path := r.URL.Path - path = strings.TrimPrefix(path, "/admin/users/delete/") + parts := strings.Split(strings.TrimSuffix(path, "/delete"), "/") + userID := parts[len(parts)-1] - if path == "" { + if userID == "" { writeInlineError(w, "Invalid user ID") return } - userID := path - currentUser, ok := r.Context().Value(webcontext.UserKey).(*database.User) if !ok || currentUser == nil { writeInlineError(w, "Not authenticated")