admin: add delete user with confirmation dialog
This commit is contained in:
@@ -7,6 +7,9 @@ SELECT * FROM user WHERE username = ? LIMIT 1;
|
||||
-- name: ListUsers :many
|
||||
SELECT * FROM user ORDER BY created_at DESC;
|
||||
|
||||
-- name: DeleteUser :exec
|
||||
DELETE FROM user WHERE id = ?;
|
||||
|
||||
-- name: CreateUser :one
|
||||
INSERT INTO user (id, username, password_hash)
|
||||
VALUES (?, ?, ?)
|
||||
|
||||
@@ -111,6 +111,8 @@ func NewRouter(cfg Config) http.Handler {
|
||||
mux.Handle("/admin/users/", middleware.RequireAdmin(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
path := r.URL.Path
|
||||
switch {
|
||||
case strings.HasSuffix(path, "/delete"):
|
||||
adminHandler.HandleDeleteUser(w, r)
|
||||
case strings.HasSuffix(path, "/watchlist"):
|
||||
adminHandler.HandleUserWatchlist(w, r)
|
||||
case strings.HasSuffix(path, "/continue-watching"):
|
||||
|
||||
Reference in New Issue
Block a user