add hashing logic and post stuff

This commit is contained in:
Adora Laura Kalb 2023-08-18 21:11:30 +02:00
parent 9580e41c59
commit e28dfbe603
Signed by: adoralaura
GPG key ID: 7A4552166FC8C056
2 changed files with 23 additions and 4 deletions

View file

@ -10,10 +10,10 @@
<!-- Favicon and title -->
<link rel="icon" href="path/to/fav.png">
<title>Starter template - Halfmoon</title>
<title>matrix.lila.network - Registration</title>
<!-- Halfmoon CSS -->
<link href="/static//halfmoon-variables.min.css" rel="stylesheet" />
<link href="/static/halfmoon-variables.min.css" rel="stylesheet" />
</head>
<body data-set-preferred-mode-onload="true">

View file

@ -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() {