self.js: delete invalid cookie before redirecting
This commit is contained in:
parent
c71d634e82
commit
12d9d52555
@ -6,8 +6,14 @@
|
||||
"ownerToken": global.cookieGet("commentoOwnerToken"),
|
||||
};
|
||||
|
||||
if (json.ownerToken === undefined) {
|
||||
document.location = "/login";
|
||||
return;
|
||||
}
|
||||
|
||||
global.post(global.commentoOrigin + "/api/owner/self", json, function(resp) {
|
||||
if (!resp.success || !resp.loggedIn) {
|
||||
global.cookieDelete("commentoOwnerToken");
|
||||
document.location = "/login";
|
||||
return;
|
||||
}
|
||||
|
@ -75,6 +75,12 @@
|
||||
}
|
||||
|
||||
|
||||
// Deletes a cookie.
|
||||
global.cookieDelete = function(name) {
|
||||
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
|
||||
}
|
||||
|
||||
|
||||
// Converts a date in the past to a human-friendly duration relative to now.
|
||||
global.timeSince = function(date) {
|
||||
var seconds = Math.floor((new Date() - date) / 1000);
|
||||
|
Loading…
Reference in New Issue
Block a user