fix backup login

This commit is contained in:
dr-frmr 2024-12-18 15:36:30 -05:00
parent 7c18d9a00f
commit 1cf5cc1811
No known key found for this signature in database
4 changed files with 12 additions and 14 deletions

View File

@ -212,10 +212,7 @@
} else {
// REMOVE IN 1.0.0
// sha256 hash password using crypto-js
const salted = ['${node}', password].join("");
const hashHex = '0x' + CryptoJS.SHA256(salted).toString(CryptoJS.enc.Hex);
const hashHex = '0x' + CryptoJS.SHA256(password).toString(CryptoJS.enc.Hex);
const result = await fetch("/login", {
method: "POST",
headers: { "Content-Type": "application/json" },
@ -224,7 +221,6 @@
subdomain: isSecureSubdomain ? firstPathItem : '',
}),
});
if (result.status == 200) {
window.location.reload();
} else {

View File

@ -883,9 +883,7 @@ async fn login_with_password(
Ok(k) => k,
Err(_) => {
use sha2::{Digest, Sha256};
let salted = [username.as_bytes(), password.as_bytes()].concat();
let password_hash = format!("0x{}", hex::encode(Sha256::digest(salted)));
let password_hash = format!("0x{}", hex::encode(Sha256::digest(password)));
keygen::decode_keyfile(&disk_keyfile, &password_hash)
.expect("could not decode keyfile, password incorrect")
}

View File

@ -73,8 +73,7 @@ function ImportKeyfile({
if (result.status > 399) {
// REMOVE IN 1.0.0
let salted = [knsName, pw].join("");
let hashed_password = sha256(toBytes(salted));
let hashed_password = sha256(toBytes(pw));
const result = await fetch("/import-keyfile", {
method: "POST",
credentials: 'include',
@ -87,10 +86,13 @@ function ImportKeyfile({
if (result.status > 399) {
throw new Error("Incorrect password");
} else {
redirectToHomepage();
}
// END REMOVE IN 1.0.0
throw new Error(await result.text());
// BRING BACK IN 1.0.0
// throw new Error(await result.text());
}
redirectToHomepage();
}).catch(err => {

View File

@ -58,8 +58,7 @@ function Login({
if (result.status > 399) {
// REMOVE IN 1.0.0
let salted = [knsName, pw].join("");
let hashed_password = sha256(toBytes(salted));
let hashed_password = sha256(toBytes(pw));
const result = await fetch(
"/login",
{
@ -71,10 +70,13 @@ function Login({
);
if (result.status > 399) {
throw new Error(await result.text());
} else {
redirectToHomepage();
}
// END REMOVE IN 1.0.0
throw new Error(await result.text());
// BRING BACK IN 1.0.0
// throw new Error(await result.text());
}
redirectToHomepage();
}).catch(err => {