fix: extract user ID from path correctly

This commit is contained in:
2026-04-22 21:43:33 +02:00
parent 1b68fd2f2a
commit aebc012eef

View File

@@ -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")