Fix: Safari does not accept document.baseURI for cookie path

This commit is contained in:
Ninh Pham 2019-10-11 13:28:25 +07:00
parent 72f1a223b4
commit e41cea6642
No known key found for this signature in database
GPG key ID: 37A4E4B9141386DE
2 changed files with 3 additions and 3 deletions

View file

@ -92,7 +92,7 @@
return response;
}).then(() => {
localStorage.removeItem("shiori-account");
document.cookie = `session-id=; Path=${document.baseURI}; Expires=Thu, 01 Jan 1970 00:00:00 GMT;`;
document.cookie = `session-id=; Path=${new URL(document.baseURI).pathname}; Expires=Thu, 01 Jan 1970 00:00:00 GMT;`;
location.href = new URL("login", document.baseURI);
}).catch(err => {
this.dialog.loading = false;

View file

@ -79,7 +79,7 @@
}
// Remove old cookie
document.cookie = `session-id=; Path=${document.baseURI}; Expires=Thu, 01 Jan 1970 00:00:00 GMT;`;
document.cookie = `session-id=; Path=${new URL(document.baseURI).pathname}; Expires=Thu, 01 Jan 1970 00:00:00 GMT;`;
// Send request
this.loading = true;
@ -99,7 +99,7 @@
}).then(json => {
// Save session id
var expTime = new Date(Date.now() + sessionAge * 3600 * 1000).toUTCString();
document.cookie = `session-id=${json.session}; Path=${document.baseURI}; Expires=${expTime}`;
document.cookie = `session-id=${json.session}; Path=${new URL(document.baseURI).pathname}; Expires=${expTime}`;
// Save account data
localStorage.setItem("shiori-account", JSON.stringify(json.account));