made modal non skippable

This commit is contained in:
maru21 2023-10-28 17:46:12 +02:00
parent cf9a4e0efb
commit 24b5b6e842
8 changed files with 19 additions and 17 deletions

View File

@ -343,6 +343,7 @@
<span <span
onclick="this.parentElement.parentElement.style.display='none'" onclick="this.parentElement.parentElement.style.display='none'"
class="w3-button w3-display-topright w3-flat-clouds" class="w3-button w3-display-topright w3-flat-clouds"
id="modalNotifierClose"
>&times;</span >&times;</span
> >
<div class="w3-container w3-padding-32 w3-flat-clouds"> <div class="w3-container w3-padding-32 w3-flat-clouds">

View File

@ -16,7 +16,7 @@ function createTemplate(template = false) {
//sessionVerfication check //sessionVerfication check
if (!passwordHash.verify()) { if (!passwordHash.verify()) {
modalNotifier("Error: Session is not authenticated...", 0); modalNotifier("Error: Session is not authenticated...", 0, false);
} }
//reset navbar if files was used //reset navbar if files was used

View File

@ -9,7 +9,6 @@ import {
checkForStoredDataOnServer, checkForStoredDataOnServer,
delStoredDataOnServer delStoredDataOnServer
} from "./web.js"; } from "./web.js";
import parseFormOnSubmit from "./parseForm.js";
import { getUsrId } from "./scripts.js"; import { getUsrId } from "./scripts.js";
function showMenu() { function showMenu() {
@ -99,11 +98,15 @@ function hideMenus(evt) {
tbBar.className = tbBar.className.replace(" w3-show", ""); tbBar.className = tbBar.className.replace(" w3-show", "");
} }
function modalNotifier(msg, timeout = 3) { function modalNotifier(msg, timeout = 3, closeable = true) {
let modalElement = document.getElementById("modalNotifier"); let modalElement = document.getElementById("modalNotifier");
let modalElementCloseBtn = document.getElementById("modalNotifierClose");
let msgElement = document.getElementById("modalMsg"); let msgElement = document.getElementById("modalMsg");
modalElement.style.display = "block"; modalElement.style.display = "block";
if (!closeable) modalElementCloseBtn.style.display = "none";
msgElement.innerHTML = msg; msgElement.innerHTML = msg;
if (timeout >= 1) { if (timeout >= 1) {
const run = setTimeout( const run = setTimeout(

View File

@ -31,7 +31,7 @@ function buildFile() {
//sessionVerfication check //sessionVerfication check
if (!passwordHash.verify()) { if (!passwordHash.verify()) {
modalNotifier("Error: Session is not authenticated...", 0); modalNotifier("Error: Session is not authenticated...", 0, false);
} }
//disable toggleFiles Button //disable toggleFiles Button

View File

@ -5,26 +5,25 @@ import getBrowserFingerprint from "./identify.js"
export const passwordHash = { export const passwordHash = {
name: cyrb53("m21_"+getBrowserFingerprint( { hardwareOnly: true } )), name: cyrb53("m21_"+getBrowserFingerprint( { hardwareOnly: true } )),
toString: () => { toString: function () {
let token = window.activeState.sessionToken; let token = window.activeState.sessionToken;
if (token === null) return "none"; if (token == null || token == "") return "none";
if (token == "") return "none" return XORCipher.decode(this.name, token);
return XORCipher.decode(passwordHash.name, token);
}, },
set: (pw) => { set: function (pw) {
activeState.sessionToken = XORCipher.encode(passwordHash.name, pw); activeState.sessionToken = XORCipher.encode(this.name, pw);
}, },
init: function () { init: function () {
//check if cookie exists //check if cookie exists
if (getCookie(sha256(passwordHash.name)) != null) { if (getCookie(sha256(this.name)) != null) {
passwordHash.set(XORCipher.decode(sha256(passwordHash.name), getCookie(sha256(passwordHash.name)))); this.set(XORCipher.decode(sha256(this.name), getCookie(sha256(this.name))));
} }
let verifiedStatus = false; let verifiedStatus = false;
let tF = retrieveData("templateFiles"); let tF = retrieveData("templateFiles");
if (tF != null) {verifiedStatus = true} if (tF != null) {verifiedStatus = true}
if (verifiedStatus == true) { if (verifiedStatus == true) {
setCookie(sha256(passwordHash.name), XORCipher.encode(sha256(passwordHash.name), passwordHash), 10) setCookie(sha256(this.name), XORCipher.encode(sha256(this.name), this), 10);
} }
}, },
verify: function () { verify: function () {
@ -104,7 +103,7 @@ function getCookie(cname) {
export function logout() { export function logout() {
let id = sha256(passwordHash.name); let id = sha256(passwordHash.name);
activeState.sessionToken = ""; activeState.sessionToken = "";
setCookie(sha256(passwordHash.name), "", 1); setCookie(sha256(passwordHash.name), "", 10);
document.cookie = id + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; document.cookie = id + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
document.getElementById("passwordField").value = ""; document.getElementById("passwordField").value = "";
document.getElementById("login").style.display = "block"; document.getElementById("login").style.display = "block";

View File

@ -16,7 +16,7 @@ const buildSettings = () => {
//sessionVerfication check //sessionVerfication check
if (!passwordHash.verify()) { if (!passwordHash.verify()) {
modalNotifier("Error: Session is not authenticated...", 0); modalNotifier("Error: Session is not authenticated...", 0, false);
} }
//reset navbar if files was used //reset navbar if files was used

View File

@ -1,7 +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, getUsrId, passwordHash, sanitize } from "./scripts.js";
import { printVersion } from "./evts.js";
const store = { const store = {
getItem: function (key) {return getStor().getItem(key)}, getItem: function (key) {return getStor().getItem(key)},

View File

@ -71,7 +71,7 @@ function loadNewTemplate(template) {
//sessionVerfication check //sessionVerfication check
if (!passwordHash.verify()) { if (!passwordHash.verify()) {
modalNotifier("Error: Session is not authenticated...", 0); modalNotifier("Error: Session is not authenticated...", 0, false);
} }
//set current page value in activeState object //set current page value in activeState object