started with cookie implementation
This commit is contained in:
parent
1d711542da
commit
6d35d3d608
@ -70,6 +70,7 @@ function setPassword() {
|
|||||||
|
|
||||||
document.getElementById("login").style.display = "none";
|
document.getElementById("login").style.display = "none";
|
||||||
window.sessionStorage.setItem(sha256("verified"), XORCipher.encode(sha256("passwordHash"), passwordHash));
|
window.sessionStorage.setItem(sha256("verified"), XORCipher.encode(sha256("passwordHash"), passwordHash));
|
||||||
|
setCookie(sha256("verified"), XORCipher.encode(sha256("passwordHash"), passwordHash.toString()), 10)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,45 +80,47 @@ export function getUsrId() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function sessionVerification() {
|
export function sessionVerification() {
|
||||||
let verfiedStatus = window.sessionStorage.getItem(sha256("verified"));
|
|
||||||
if (verfiedStatus == '') {verfiedStatus = null}
|
|
||||||
if (verfiedStatus != null) {
|
|
||||||
//user logged in
|
|
||||||
|
|
||||||
//write verifiedStatus content into passwordHash for decode check later
|
//check if cookie exists
|
||||||
//passwordHash.set(XORCipher.decode(sha256("passwordHash"), verfiedStatus));
|
if (getCookie(sha256("verified")) != null) {
|
||||||
//document.getElementById("login").style.display = "none";
|
passwordHash.set(XORCipher.decode(sha256("passwordHash"), getCookie(sha256("verified"))));
|
||||||
//load NavigationBar with templates according to server
|
window.sessionStorage.setItem(sha256("verified"), XORCipher.encode(sha256("passwordHash"), passwordHash));
|
||||||
|
}
|
||||||
let data;
|
|
||||||
try {
|
let verfiedStatus = window.sessionStorage.getItem(sha256("verified"));
|
||||||
data = window.sessionStorage.getItem(sha256(passwordHash.name));
|
let data;
|
||||||
} catch (e) {
|
try {
|
||||||
verfiedStatus = null;
|
data = window.sessionStorage.getItem(sha256(passwordHash.name));
|
||||||
}
|
} catch (e) {
|
||||||
if (data === null) verfiedStatus = null;
|
verfiedStatus = null;
|
||||||
|
}
|
||||||
let tF = retrieveData("templateFiles");
|
if (data === null) verfiedStatus = null;
|
||||||
try {
|
|
||||||
tF = JSON.parse(tF);
|
//if (verfiedStatus != data) verfiedStatus = null
|
||||||
} catch(e) {
|
let vsString;
|
||||||
verfiedStatus = null;
|
let pnString;
|
||||||
}
|
try {
|
||||||
|
vsString = XORCipher.decode(sha256("passwordHash"), verfiedStatus);
|
||||||
} else {
|
pnString = XORCipher.decode(passwordHash.name, data);
|
||||||
//check if cookie exists
|
if (vsString != pnString) verfiedStatus = null;
|
||||||
if (getCookie(sha256("verified")) != null) {
|
} catch (e) {
|
||||||
//passwordHash.set(XORCipher.decode(sha256("passwordHash"), getCookie(sha256("verified"))));
|
verfiedStatus = null;
|
||||||
//document.getElementById("login").style.display = "none";
|
}
|
||||||
//load NavigationBar with templates according to server
|
|
||||||
//initweb();
|
let tF = retrieveData("templateFiles");
|
||||||
} else {
|
try {
|
||||||
//document.getElementById("login").style.display = "block";
|
tF = JSON.parse(tF);
|
||||||
}
|
} catch(e) {
|
||||||
|
verfiedStatus = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verfiedStatus == null) {
|
||||||
|
console.log('v: ',verfiedStatus);
|
||||||
|
alert("Decryption failed; are you authenticated?");
|
||||||
|
window.location.reload();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verfiedStatus == null) window.stop();
|
|
||||||
console.log('v: ',verfiedStatus);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const cyrb53 = (str, seed = 21) => {
|
const cyrb53 = (str, seed = 21) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user