fixed token setting
This commit is contained in:
parent
5109d75e1a
commit
4fe6704e72
1 changed files with 9 additions and 5 deletions
|
@ -2,7 +2,7 @@ function setTokenCookie() {
|
|||
let token = document.getElementById('set-token').value;
|
||||
let tokenCookie = 'token=' + token + "; SameSite=None; secure";
|
||||
document.cookie = tokenCookie;
|
||||
document.getElementById("token").value = token
|
||||
setFormTokens(token);
|
||||
document.getElementById("cookie-block").hidden = true;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,13 @@ function clearTokenCookie() {
|
|||
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;
|
||||
|
@ -18,10 +25,7 @@ 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];
|
||||
let tokenFields = document.querySelectorAll(".token");
|
||||
for (t of tokenFields) {
|
||||
t.value = token;
|
||||
}
|
||||
setFormTokens(token);
|
||||
cookie_set = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue