Updated JS stuffs.
This commit is contained in:
parent
1363bf5bca
commit
452eeb22d6
21 changed files with 267 additions and 412 deletions
24
assets/makai.js/csrf.js
Normal file
24
assets/makai.js/csrf.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include html.js
|
||||
|
||||
const $csrf = (() => {
|
||||
let elem;
|
||||
const getElement = () => {
|
||||
if(elem === undefined)
|
||||
elem = $query('meta[name="csrf-token"]');
|
||||
return elem;
|
||||
};
|
||||
|
||||
return {
|
||||
get token() {
|
||||
return getElement()?.content ?? '';
|
||||
},
|
||||
set token(token) {
|
||||
if(typeof token !== 'string')
|
||||
throw 'token must be a string';
|
||||
|
||||
const elem = getElement();
|
||||
if(elem instanceof HTMLMetaElement)
|
||||
elem.content = token;
|
||||
},
|
||||
};
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue