0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Used return value of {set,remove}Cookie

no-issue

Soon these functions will make network calls, returning them allows us to use promises
This commit is contained in:
Fabien O'Carroll 2019-04-10 17:05:11 +02:00
parent 02468bfe0c
commit db74ef3d1a

View file

@ -36,10 +36,12 @@ function setupMembersListeners() {
const claims = getClaims(token); const claims = getClaims(token);
const expiry = new Date(claims.exp * 1000); const expiry = new Date(claims.exp * 1000);
document.cookie = 'member=' + token + ';Path=/;expires=' + expiry.toUTCString(); document.cookie = 'member=' + token + ';Path=/;expires=' + expiry.toUTCString();
return true;
} }
function removeCookie() { function removeCookie() {
document.cookie = 'member=null;Path=/;max-age=0'; document.cookie = 'member=null;Path=/;max-age=0';
return true;
} }
members.on('signedin', function () { members.on('signedin', function () {
@ -65,8 +67,7 @@ function setupMembersListeners() {
event.preventDefault(); event.preventDefault();
members.signout() members.signout()
.then(() => { .then(() => {
removeCookie(); return removeCookie();
return true;
}) })
.then(reload); .then(reload);
} }
@ -79,8 +80,7 @@ function setupMembersListeners() {
audience: tokenAudience, audience: tokenAudience,
fresh: true fresh: true
}).then(function (token) { }).then(function (token) {
setCookie(token); return setCookie(token);
return true;
}); });
}) })
.then(reload); .then(reload);
@ -94,8 +94,7 @@ function setupMembersListeners() {
audience: tokenAudience, audience: tokenAudience,
fresh: true fresh: true
}).then(function (token) { }).then(function (token) {
setCookie(token); return setCookie(token);
return true;
}); });
}) })
.then(reload); .then(reload);