diff --git a/Slon/Http/AdminServer.HC b/Slon/Http/AdminServer.HC
index 235a970..c0df488 100644
--- a/Slon/Http/AdminServer.HC
+++ b/Slon/Http/AdminServer.HC
@@ -227,6 +227,25 @@ U0 @slon_admin_settings_instance_get(SlonHttpSession* session, U8* buf)
String.Append(buf, "
");
}
+U0 @slon_admin_delete_account(SlonHttpSession* session)
+{
+ SLON_SCRATCH_BUFFER_AND_REQUEST_JSON
+ if (!request_json->@("id"))
+ return;
+ I64 i;
+ JsonArray* accounts = db->a("accounts");
+ JsonObject* account = NULL;
+ for (i = 0; i < accounts->length; i++) {
+ account = accounts->o(i);
+ if (account && !StrICmp(request_json->@("id"), account->@("id"))) {
+ accounts->remove(i);
+ break;
+ }
+ }
+ @slon_db_save_to_disk;
+ @slon_http_send_json(session, SLON_EMPTY_JSON_OBJECT);
+}
+
U0 @slon_admin_new_account(SlonHttpSession* session)
{
SLON_SCRATCH_BUFFER_AND_REQUEST_JSON
@@ -276,6 +295,11 @@ U0 @slon_admin_server_get(SlonHttpSession* session)
return;
}
+ if (!StrICmp("/delete/account", @slon_http_request_path(session))) {
+ @slon_admin_delete_account(session);
+ return;
+ }
+
if (!StrICmp("/manage/accounts", @slon_http_request_path(session))) {
@slon_admin_manage_accounts(session);
return;
diff --git a/Slon/Static/html/admin/main.html b/Slon/Static/html/admin/main.html
index 08ff19e..4a3dc79 100644
--- a/Slon/Static/html/admin/main.html
+++ b/Slon/Static/html/admin/main.html
@@ -70,9 +70,9 @@
const accounts = await response.json();
let html = "
Accounts
";
if (accounts.length) {
- html += "id | username |
";
+ html += "id | acct | display_name | type | delete |
";
for (let i = 0; i < accounts.length; i++) {
- html += "" + accounts[i]["id"] + " | " + accounts[i]["username"] + " |
";
+ html += "
" + accounts[i]["id"] + " | " + accounts[i]["acct"] + " | " + accounts[i]["display_name"] + " | "+ (accounts[i]["remote_actor"] == undefined ? "local" : "remote") + " | ❌ |
";
}
html += "
";
} else {
@@ -82,6 +82,14 @@
setContent(html);
setActiveLink("accounts");
}
+ async function confirmDeleteUser(user, id) {
+ if(confirm("Are you sure you want to delete '" + user + "' ?")) {
+ const request = new Request("/delete/account?id=" + id);
+ const response = await fetch(request);
+ const empty_json = await response.json();
+ manageAccounts();
+ }
+ }
function manageNewUser() {
clearActiveLinks();
let html = "New User
";