diff src/private/tools/delete_user.html.luan @ 4:028e74c8889d

add all_users
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 12 May 2022 16:54:11 -0600
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/private/tools/delete_user.html.luan	Thu May 12 16:54:11 2022 -0600
@@ -0,0 +1,41 @@
+local Luan = require "luan:Luan.luan"
+local error = Luan.error
+local Io = require "luan:Io.luan"
+local Http = require "luan:http/Http.luan"
+local Shared = require "site:/lib/Shared.luan"
+local head = Shared.head or error()
+local header = Shared.private_header or error()
+local config = Shared.config or error()
+local user_repos = Shared.user_repos or error()
+local get_raw_config = Shared.get_raw_config or error()
+local save_raw_config = Shared.save_raw_config or error()
+
+
+local function handle()
+	local user = Http.request.parameters.user or error()
+	user_repos[user] and error "has repos"
+	local raw_config = get_raw_config()
+	raw_config.users[user] = nil
+	save_raw_config(raw_config)
+	return [[<p>User <b>]]..user..[[</b> has been deleted</p>]]
+end
+
+return function()
+	Io.stdout = Http.response.text_writer()
+%>
+<!doctype html>
+<html>
+	<head>
+<%		head() %>
+		<title>Delete Mercurial User</title>
+	</head>
+	<body>
+<%		header() %>
+		<div content>
+			<h1>Delete User</h1>
+			<%=handle()%>
+		</div>
+	</body>
+</html>
+<%
+end