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

View File

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

View File

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

View File

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