fixed getUsrId usage

This commit is contained in:
maru21 2023-10-28 21:25:35 +02:00
parent b6fde65054
commit 600eab77f4
5 changed files with 11 additions and 15 deletions

View File

@ -9,7 +9,6 @@ import {
checkForStoredDataOnServer,
delStoredDataOnServer
} from "./web.js";
import { getUsrId } from "./scripts.js";
function showMenu() {
var x = document.getElementById("navMob");
@ -174,7 +173,7 @@ function clickImportFiles() {
modal.replaceWith(modal.cloneNode(true));
modalNotifier(
"Files saved to server <br><br> would you like to <a href='/storage/" +
getUsrId() +
activeState.userId +
".txt' style='text-decoration: underline;' download>download</a> them?"
,0);
break;

View File

@ -10,8 +10,7 @@ import {
import { buildFile } from "./files.js";
import setPassword, {
passwordHash,
inputRead,
getUsrId,
inputRead
} from "./scripts.js";
import parseFormOnSubmit from "./parseForm.js";
import { createStorageObj, storeSettings } from "./storage.js";
@ -54,10 +53,6 @@ function init() {
//init passwordhash to retrieve cookie info and set passwordHash
passwordHash.initHash();
//set user id
activeState.userId = getUsrId();
//check if user is logged in
if (passwordHash.verify()) {
//user logged in

View File

@ -28,6 +28,8 @@ export const passwordHash = {
if (verifiedStatus == true) {
//set user id
activeState.userId = getUsrId();
setCookie(sha256(this.name), XORCipher.encode(sha256(this.name), this), 10);
}
},
@ -95,7 +97,7 @@ function cyrb53(str, seed = 21) {
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
}
export function getUsrId() {
function getUsrId() {
const fingerprint = getBrowserFingerprint( { hardwareOnly: true } );
return cyrb53(fingerprint + passwordHash);
}

View File

@ -1,6 +1,6 @@
import XORCipher from "./xorc.js";
import sha256 from "./sha256.min.js";
import { getCurrentDate, getUsrId, passwordHash, sanitize } from "./scripts.js";
import { getCurrentDate, passwordHash, sanitize } from "./scripts.js";
const store = {
getItem: function (key) {return getStor().getItem(key)},
@ -211,7 +211,7 @@ function createBookShelf() {
let saveFileName = date.current_time + "_" + date.current_date;
if (tF != null) {
bookShelf[0] = { name: "hash", data: getUsrId(), ts: saveFileName };
bookShelf[0] = { name: "hash", data: activeState.userId, ts: saveFileName };
let i = 1;
for (let tFi of tF) {
let data = retrieveData(tFi.fileName, tFi.template);
@ -255,7 +255,7 @@ function importBookShelf() {
}
}
};
xhttp.open("GET", "php/?getStoredFiles=" + getUsrId(), true);
xhttp.open("GET", "php/?getStoredFiles=" + activeState.userId, true);
xhttp.setRequestHeader(
"Content-type",
"application/x-www-form-urlencoded; charset=UTF-8"

View File

@ -3,7 +3,7 @@ import { loadFileDivCallBack } from "./files.js";
import { retrieveData, clearData, getFileName } from "./storage.js";
import { insertTextBlocks, modalNotifier, resetNavBar } from "./evts.js";
import { createTemplate, createTemplateCallBack} from "./createTemplate.js";
import { getUsrId, logout, passwordHash } from "./scripts.js";
import { logout, passwordHash } from "./scripts.js";
import buildSettings from "./settings.js";
@ -264,7 +264,7 @@ function checkForStoredDataOnServer() {
}
}
};
xhttp.open("GET", "php/?storedFiles="+getUsrId(), true);
xhttp.open("GET", "php/?storedFiles="+activeState.userId, true);
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=UTF-8');
xhttp.send();
}
@ -279,7 +279,7 @@ function delStoredDataOnServer() {
}
}
};
xhttp.open("GET", "php/?storedFiles="+getUsrId()+"&del", true);
xhttp.open("GET", "php/?storedFiles="+activeState.userId+"&del", true);
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=UTF-8');
xhttp.send();
}