Add adduser to admin view
This commit is contained in:
parent
3047a6de77
commit
cd3c8dd4f8
2
model.py
2
model.py
@ -101,6 +101,8 @@ class Model(object):
|
|||||||
|
|
||||||
@ApiMethod
|
@ApiMethod
|
||||||
async def add_user(self, authtoken, username):
|
async def add_user(self, authtoken, username):
|
||||||
|
if username == "":
|
||||||
|
raise Exception("Username can't be blank!")
|
||||||
self.verify_admin(authtoken)
|
self.verify_admin(authtoken)
|
||||||
newuser = User(username = username)
|
newuser = User(username = username)
|
||||||
self.users[newuser.uuid] = newuser
|
self.users[newuser.uuid] = newuser
|
||||||
|
@ -27,6 +27,25 @@ Object.defineProperty(String.prototype, 'hashCode', {
|
|||||||
function render_table(data) {
|
function render_table(data) {
|
||||||
const users = Object.values(data.users);
|
const users = Object.values(data.users);
|
||||||
|
|
||||||
|
const newusername = document.querySelector("#newusername");
|
||||||
|
const newuserbutton = document.querySelector("#newuserbutton");
|
||||||
|
|
||||||
|
newuserbutton.addEventListener("click", async () => {
|
||||||
|
const r = await fetch(admin_api_path + 'add_user', {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({
|
||||||
|
username: newusername.value,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (r.status !== 200) {
|
||||||
|
console.log("something went wrong");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
update_table();
|
||||||
|
})
|
||||||
|
|
||||||
const tbody = document.querySelector("#scoreboard tbody");
|
const tbody = document.querySelector("#scoreboard tbody");
|
||||||
|
|
||||||
while (tbody.children.length) {
|
while (tbody.children.length) {
|
||||||
|
Loading…
Reference in New Issue
Block a user