remove cookie token garbage

This commit is contained in:
mtrx 2024-08-10 09:41:01 +02:00
parent ed0c6b4f0a
commit 7fe997acff
12 changed files with 164 additions and 235 deletions

View file

@ -10,13 +10,18 @@ html {
padding-left: 20%;
}
img {
.social-icon {
height: 1rem;
width: 1rem;
}
.post-img {
width: 50%;
padding: 20px 0px 20px 0px;
}
article {
padding-top: 2em;
padding-top: 2rem;
display: flex;
}
@ -29,20 +34,21 @@ article {
}
.post-publish-date {
font-size: 0.7em;
font-size: 0.7rem;
}
.post-body {
padding-top: 1em;
padding-top: 1rem;
}
#submit-form {
padding-top: 2em;
padding-top: 2rem;
}
#submit-body, #submit-title {
#submit-body,
#submit-title {
width: 100%;
margin-bottom: 2em;
margin-bottom: 2rem;
resize: none;
}
@ -60,4 +66,4 @@ article {
width: 90%;
padding-left: 5%;
}
}
}

View file

@ -1,24 +0,0 @@
* {
margin: 0;
padding: 0;
}
html {
font-family: sans-serif;
padding: 20px;
width: 60%;
padding-left: 20%;
}
.social-icon {
height: 1em;
width: 1em;
}
@media (max-width:1080px) {
html {
font-family: sans-serif;
padding: 20px;
width: 90%;
padding-left: 5%;
}

View file

@ -1,35 +0,0 @@
function setTokenCookie() {
let token = document.getElementById('set-token').value;
let tokenCookie = 'token=' + token + "; SameSite=None; secure";
document.cookie = tokenCookie;
setFormTokens(token);
document.getElementById("cookie-block").hidden = true;
}
function clearTokenCookie() {
document.cookie = "token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; SameSite=None; secure";
document.getElementById("cookie-block").hidden = false;
}
function setFormTokens(token) {
let tokenFields = document.querySelectorAll(".token");
for (t of tokenFields) {
t.value = token;
}
}
// if cookie is set, use it to pass the token
let c_pairs = document.cookie.split(";");
let cookie_set = false;
for (c of c_pairs) {
if (c.trim().split("=")[0].startsWith("token")){
// stick token into all the form input fields
let token = c.split("=")[1];
setFormTokens(token);
cookie_set = true;
}
}
if (!cookie_set) {
document.getElementById("cookie-block").hidden = false;
}