diff --git a/index.html b/index.html index 5427cbd..092ec27 100644 --- a/index.html +++ b/index.html @@ -10,10 +10,10 @@ - Starter template - Halfmoon + matrix.lila.network - Registration - + diff --git a/static/script.js b/static/script.js index 7d6fe9b..73d74c0 100644 --- a/static/script.js +++ b/static/script.js @@ -1,4 +1,4 @@ -async function handleSubmit() { +async function submitForm() { var nonce_request = await fetch("https://matrix-reg.test.lauka.dev/_synapse/admin/v1/register", { method: 'GET', redirect: 'follow', @@ -7,6 +7,7 @@ async function handleSubmit() { var nonce = await nonce_request.json() var username = document.getElementById("username").value + var displayname = document.getElementById("displayname").value var password = document.getElementById("password").value var sharedsecret = document.getElementById("sharedsecret").value var admin = "notadmin" @@ -14,7 +15,25 @@ async function handleSubmit() { var string = `${nonce.nonce}\0${username}\0${password}\0${admin}` - const hash = new jsSHA("SHA-1", "TEXT", { hmacKey : { value : sharedsecret, format: "TEXT" }}) + const hasher = new jsSHA("SHA-1", "TEXT", { hmacKey : { value : sharedsecret, format: "TEXT" }}) + hasher.update(string) + var hmac = hasher.getHash('HEX') + + var register_body = JSON.stringify({ + "nonce": nonce.nonce, + "username": displayname, + "password": password, + "admin": false, + "mac": hmac + }) + + var register_request = await fetch("https://matrix-reg.test.lauka.dev/_synapse/admin/v1/register", { + method: 'POST', + mode: "cors", + body: register_body + }) + + } function HandlePasswordInput() {