fixed getUsrId usage
This commit is contained in:
parent
b6fde65054
commit
600eab77f4
@ -9,7 +9,6 @@ import {
|
|||||||
checkForStoredDataOnServer,
|
checkForStoredDataOnServer,
|
||||||
delStoredDataOnServer
|
delStoredDataOnServer
|
||||||
} from "./web.js";
|
} from "./web.js";
|
||||||
import { getUsrId } from "./scripts.js";
|
|
||||||
|
|
||||||
function showMenu() {
|
function showMenu() {
|
||||||
var x = document.getElementById("navMob");
|
var x = document.getElementById("navMob");
|
||||||
@ -174,7 +173,7 @@ function clickImportFiles() {
|
|||||||
modal.replaceWith(modal.cloneNode(true));
|
modal.replaceWith(modal.cloneNode(true));
|
||||||
modalNotifier(
|
modalNotifier(
|
||||||
"Files saved to server <br><br> would you like to <a href='/storage/" +
|
"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?"
|
".txt' style='text-decoration: underline;' download>download</a> them?"
|
||||||
,0);
|
,0);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -10,8 +10,7 @@ import {
|
|||||||
import { buildFile } from "./files.js";
|
import { buildFile } from "./files.js";
|
||||||
import setPassword, {
|
import setPassword, {
|
||||||
passwordHash,
|
passwordHash,
|
||||||
inputRead,
|
inputRead
|
||||||
getUsrId,
|
|
||||||
} from "./scripts.js";
|
} from "./scripts.js";
|
||||||
import parseFormOnSubmit from "./parseForm.js";
|
import parseFormOnSubmit from "./parseForm.js";
|
||||||
import { createStorageObj, storeSettings } from "./storage.js";
|
import { createStorageObj, storeSettings } from "./storage.js";
|
||||||
@ -54,10 +53,6 @@ function init() {
|
|||||||
//init passwordhash to retrieve cookie info and set passwordHash
|
//init passwordhash to retrieve cookie info and set passwordHash
|
||||||
passwordHash.initHash();
|
passwordHash.initHash();
|
||||||
|
|
||||||
//set user id
|
|
||||||
activeState.userId = getUsrId();
|
|
||||||
|
|
||||||
|
|
||||||
//check if user is logged in
|
//check if user is logged in
|
||||||
if (passwordHash.verify()) {
|
if (passwordHash.verify()) {
|
||||||
//user logged in
|
//user logged in
|
||||||
|
|||||||
@ -28,6 +28,8 @@ export const passwordHash = {
|
|||||||
|
|
||||||
|
|
||||||
if (verifiedStatus == true) {
|
if (verifiedStatus == true) {
|
||||||
|
//set user id
|
||||||
|
activeState.userId = getUsrId();
|
||||||
setCookie(sha256(this.name), XORCipher.encode(sha256(this.name), this), 10);
|
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);
|
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getUsrId() {
|
function getUsrId() {
|
||||||
const fingerprint = getBrowserFingerprint( { hardwareOnly: true } );
|
const fingerprint = getBrowserFingerprint( { hardwareOnly: true } );
|
||||||
return cyrb53(fingerprint + passwordHash);
|
return cyrb53(fingerprint + passwordHash);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import XORCipher from "./xorc.js";
|
import XORCipher from "./xorc.js";
|
||||||
import sha256 from "./sha256.min.js";
|
import sha256 from "./sha256.min.js";
|
||||||
import { getCurrentDate, getUsrId, passwordHash, sanitize } from "./scripts.js";
|
import { getCurrentDate, passwordHash, sanitize } from "./scripts.js";
|
||||||
|
|
||||||
const store = {
|
const store = {
|
||||||
getItem: function (key) {return getStor().getItem(key)},
|
getItem: function (key) {return getStor().getItem(key)},
|
||||||
@ -211,7 +211,7 @@ function createBookShelf() {
|
|||||||
let saveFileName = date.current_time + "_" + date.current_date;
|
let saveFileName = date.current_time + "_" + date.current_date;
|
||||||
|
|
||||||
if (tF != null) {
|
if (tF != null) {
|
||||||
bookShelf[0] = { name: "hash", data: getUsrId(), ts: saveFileName };
|
bookShelf[0] = { name: "hash", data: activeState.userId, ts: saveFileName };
|
||||||
let i = 1;
|
let i = 1;
|
||||||
for (let tFi of tF) {
|
for (let tFi of tF) {
|
||||||
let data = retrieveData(tFi.fileName, tFi.template);
|
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(
|
xhttp.setRequestHeader(
|
||||||
"Content-type",
|
"Content-type",
|
||||||
"application/x-www-form-urlencoded; charset=UTF-8"
|
"application/x-www-form-urlencoded; charset=UTF-8"
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { loadFileDivCallBack } from "./files.js";
|
|||||||
import { retrieveData, clearData, getFileName } from "./storage.js";
|
import { retrieveData, clearData, getFileName } from "./storage.js";
|
||||||
import { insertTextBlocks, modalNotifier, resetNavBar } from "./evts.js";
|
import { insertTextBlocks, modalNotifier, resetNavBar } from "./evts.js";
|
||||||
import { createTemplate, createTemplateCallBack} from "./createTemplate.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";
|
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.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=UTF-8');
|
||||||
xhttp.send();
|
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.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=UTF-8');
|
||||||
xhttp.send();
|
xhttp.send();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user