add hashing logic and post stuff
This commit is contained in:
parent
9580e41c59
commit
e28dfbe603
2 changed files with 23 additions and 4 deletions
|
@ -10,10 +10,10 @@
|
||||||
|
|
||||||
<!-- Favicon and title -->
|
<!-- Favicon and title -->
|
||||||
<link rel="icon" href="path/to/fav.png">
|
<link rel="icon" href="path/to/fav.png">
|
||||||
<title>Starter template - Halfmoon</title>
|
<title>matrix.lila.network - Registration</title>
|
||||||
|
|
||||||
<!-- Halfmoon CSS -->
|
<!-- Halfmoon CSS -->
|
||||||
<link href="/static//halfmoon-variables.min.css" rel="stylesheet" />
|
<link href="/static/halfmoon-variables.min.css" rel="stylesheet" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body data-set-preferred-mode-onload="true">
|
<body data-set-preferred-mode-onload="true">
|
||||||
|
|
|
@ -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", {
|
var nonce_request = await fetch("https://matrix-reg.test.lauka.dev/_synapse/admin/v1/register", {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
redirect: 'follow',
|
redirect: 'follow',
|
||||||
|
@ -7,6 +7,7 @@ async function handleSubmit() {
|
||||||
var nonce = await nonce_request.json()
|
var nonce = await nonce_request.json()
|
||||||
|
|
||||||
var username = document.getElementById("username").value
|
var username = document.getElementById("username").value
|
||||||
|
var displayname = document.getElementById("displayname").value
|
||||||
var password = document.getElementById("password").value
|
var password = document.getElementById("password").value
|
||||||
var sharedsecret = document.getElementById("sharedsecret").value
|
var sharedsecret = document.getElementById("sharedsecret").value
|
||||||
var admin = "notadmin"
|
var admin = "notadmin"
|
||||||
|
@ -14,7 +15,25 @@ async function handleSubmit() {
|
||||||
var string = `${nonce.nonce}\0${username}\0${password}\0${admin}`
|
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() {
|
function HandlePasswordInput() {
|
||||||
|
|
Loading…
Reference in a new issue