diff --git a/kinode/src/http/login.html b/kinode/src/http/login.html index e33d3971..9f61b9d3 100644 --- a/kinode/src/http/login.html +++ b/kinode/src/http/login.html @@ -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 { diff --git a/kinode/src/main.rs b/kinode/src/main.rs index 458ea508..786c5ce5 100644 --- a/kinode/src/main.rs +++ b/kinode/src/main.rs @@ -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") } diff --git a/kinode/src/register-ui/src/pages/ImportKeyfile.tsx b/kinode/src/register-ui/src/pages/ImportKeyfile.tsx index 121b6694..b052cf5d 100644 --- a/kinode/src/register-ui/src/pages/ImportKeyfile.tsx +++ b/kinode/src/register-ui/src/pages/ImportKeyfile.tsx @@ -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 => { diff --git a/kinode/src/register-ui/src/pages/Login.tsx b/kinode/src/register-ui/src/pages/Login.tsx index 8e6fd296..d5b5ce76 100644 --- a/kinode/src/register-ui/src/pages/Login.tsx +++ b/kinode/src/register-ui/src/pages/Login.tsx @@ -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 => {