fix: extract user ID from path correctly
This commit is contained in:
@@ -88,15 +88,14 @@ func (h *Handler) HandleAddUserForm(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
func (h *Handler) HandleDeleteUserRouter(w http.ResponseWriter, r *http.Request) {
|
func (h *Handler) HandleDeleteUserRouter(w http.ResponseWriter, r *http.Request) {
|
||||||
path := r.URL.Path
|
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")
|
writeInlineError(w, "Invalid user ID")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
userID := path
|
|
||||||
|
|
||||||
currentUser, ok := r.Context().Value(webcontext.UserKey).(*database.User)
|
currentUser, ok := r.Context().Value(webcontext.UserKey).(*database.User)
|
||||||
if !ok || currentUser == nil {
|
if !ok || currentUser == nil {
|
||||||
writeInlineError(w, "Not authenticated")
|
writeInlineError(w, "Not authenticated")
|
||||||
|
|||||||
Reference in New Issue
Block a user