mirror of
https://github.com/YunoHost/dynette.git
synced 2024-09-03 20:06:17 +02:00
async/await in delete interface to avoid a whole indent level
This commit is contained in:
parent
88a30a6656
commit
f8452bdcc5
1 changed files with 23 additions and 26 deletions
49
delete.html
49
delete.html
|
@ -101,45 +101,42 @@ async function sha256(message) {
|
||||||
/* END SHA256 CODE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
/* END SHA256 CODE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|
||||||
function sendDeleteRequest()
|
async function sendDeleteRequest()
|
||||||
{
|
{
|
||||||
// Compute 'true' password
|
// Compute 'true' password
|
||||||
var domain = document.getElementById("domain").value;
|
var domain = document.getElementById("domain").value;
|
||||||
var user_password = document.getElementById("password").value;
|
var user_password = document.getElementById("password").value;
|
||||||
var true_password;
|
var true_password = await sha256(domain+":"+user_password);
|
||||||
sha256(domain+":"+user_password).then(function(d) {
|
|
||||||
var true_password = d;
|
|
||||||
|
|
||||||
// Prepare request
|
// Prepare request
|
||||||
var url = "./domains/"+domain
|
var url = "./domains/"+domain
|
||||||
var params = "recovery_password="+true_password;
|
var params = "recovery_password="+true_password;
|
||||||
var xhttp = new XMLHttpRequest();
|
var xhttp = new XMLHttpRequest();
|
||||||
|
|
||||||
// Prepare handler
|
// Prepare handler
|
||||||
xhttp.onreadystatechange = function()
|
xhttp.onreadystatechange = function()
|
||||||
|
{
|
||||||
|
if (xhttp.readyState == 4)
|
||||||
{
|
{
|
||||||
if (xhttp.readyState == 4)
|
if (xhttp.status == 200)
|
||||||
{
|
{
|
||||||
if (xhttp.status == 200)
|
document.getElementById("debug").innerHTML = xhttp.responseText;
|
||||||
{
|
|
||||||
document.getElementById("debug").innerHTML = xhttp.responseText;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
document.getElementById("debug").innerHTML = "Error ? " + xhttp.responseText;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
document.getElementById("debug").innerHTML = "Sending request...";
|
document.getElementById("debug").innerHTML = "Error ? " + xhttp.responseText;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
document.getElementById("debug").innerHTML = "Sending request...";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Actually send the request
|
// Actually send the request
|
||||||
xhttp.open("DELETE", url, true);
|
xhttp.open("DELETE", url, true);
|
||||||
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||||
xhttp.send(params);
|
xhttp.send(params);
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Reference in a new issue