mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Removed hardcoded url values
no-issue This gives greater flexibility in the application which handles the urls for this, allowing the urls to be changed and configured in only one codebase.
This commit is contained in:
parent
ca998d0529
commit
979af9f234
1 changed files with 10 additions and 10 deletions
|
@ -4,8 +4,8 @@ const browserAuth = require('@tryghost/members-browser-auth');
|
||||||
|
|
||||||
module.exports.init = init;
|
module.exports.init = init;
|
||||||
|
|
||||||
function init({siteUrl}) {
|
function init({membersUrl, ssrUrl}) {
|
||||||
const auth = browserAuth({membersUrl: siteUrl + '/members'});
|
const auth = browserAuth({membersUrl});
|
||||||
|
|
||||||
const [hashMatch, hash, query] = window.location.hash.match(/^#([^?]+)\??(.*)$/) || [];
|
const [hashMatch, hash, query] = window.location.hash.match(/^#([^?]+)\??(.*)$/) || [];
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ function init({siteUrl}) {
|
||||||
function signout() {
|
function signout() {
|
||||||
auth.signout()
|
auth.signout()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return destroySession();
|
return destroySession(ssrUrl);
|
||||||
})
|
})
|
||||||
.then(reload);
|
.then(reload);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ function init({siteUrl}) {
|
||||||
return auth.getSSRToken({
|
return auth.getSSRToken({
|
||||||
fresh: true
|
fresh: true
|
||||||
}).then(function (token) {
|
}).then(function (token) {
|
||||||
return createSession(token);
|
return createSession(token, ssrUrl);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(reload);
|
.then(reload);
|
||||||
|
@ -57,7 +57,7 @@ function init({siteUrl}) {
|
||||||
return auth.getSSRToken({
|
return auth.getSSRToken({
|
||||||
fresh: true
|
fresh: true
|
||||||
}).then(function (token) {
|
}).then(function (token) {
|
||||||
return createSession(token);
|
return createSession(token, ssrUrl);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(reload);
|
.then(reload);
|
||||||
|
@ -69,7 +69,7 @@ function init({siteUrl}) {
|
||||||
return auth.getSSRToken({
|
return auth.getSSRToken({
|
||||||
fresh: true
|
fresh: true
|
||||||
}).then(function (token) {
|
}).then(function (token) {
|
||||||
return createSession(token);
|
return createSession(token, ssrUrl);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(reload);
|
.then(reload);
|
||||||
|
@ -116,8 +116,8 @@ function reload(success) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createSession(token) {
|
function createSession(token, ssrUrl) {
|
||||||
return fetch('/members/ssr', {
|
return fetch(ssrUrl, {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
body: token
|
body: token
|
||||||
|
@ -126,8 +126,8 @@ function createSession(token) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroySession() {
|
function destroySession(ssrUrl) {
|
||||||
return fetch('/members/ssr', {
|
return fetch(ssrUrl, {
|
||||||
method: 'delete'
|
method: 'delete'
|
||||||
}).then(function (res) {
|
}).then(function (res) {
|
||||||
return !!res.ok;
|
return !!res.ok;
|
||||||
|
|
Loading…
Add table
Reference in a new issue