using now session cookies to store protectedSessionId

This commit is contained in:
zadam
2019-03-13 21:53:09 +01:00
parent 24c8b39d8e
commit b4c6d9f800
9 changed files with 31 additions and 27 deletions

View File

@@ -164,11 +164,23 @@ function isDesktop() {
|| (!window.device && !/Mobi/.test(navigator.userAgent));
}
// cookie code below works for simple use cases only - ASCII only
// not setting path so that cookies do not leak into other websites if multiplexed with reverse proxy
function setCookie(name, value) {
const date = new Date(Date.now() + 10 * 365 * 24 * 60 * 60 * 1000);
const expires = "; expires=" + date.toUTCString();
document.cookie = name + "=" + (value || "") + expires + "; path=/";
document.cookie = name + "=" + (value || "") + expires + ";";
}
function setSessionCookie(name, value) {
document.cookie = name + "=" + (value || "") + ";";
}
function getCookie(name) {
const valueMatch = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
return valueMatch ? valueMatch[2] : null;
}
function getNoteTypeClass(type) {
@@ -213,6 +225,8 @@ export default {
isMobile,
isDesktop,
setCookie,
setSessionCookie,
getCookie,
getNoteTypeClass,
getMimeTypeClass
};