3e5a62309f
refs #9865 - removed all `oauth2` and token-based ESA auth - added new `cookie` authenticator which handles session creation - updated the session store to extend from the `ephemeral` in-memory store and to restore by fetching the currently logged in user and using the success/failure state to indicate authentication state - ESA automatically calls this `.restore()` method on app boot - the `session` service caches the current-user query so there's no unnecessary requests being made for the "logged in" state - removed the now-unnecessary token refresh and logout routines from the `application` route - removed the now-unnecessary token refresh routines from the `ajax` service - removed `access_token` query param from iframe file downloaders - changed Ember Data adapters and `ghost-paths` to use the `/ghost/api/v2/admin/` namespace
58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
let makeRoute = function (root, args) {
|
|
let slashAtStart = /^\//;
|
|
let slashAtEnd = /\/$/;
|
|
let parts = Array.prototype.slice.call(args, 0);
|
|
let route = root.replace(slashAtEnd, '');
|
|
|
|
parts.forEach((part) => {
|
|
if (part) {
|
|
route = [route, part.replace(slashAtStart, '').replace(slashAtEnd, '')].join('/');
|
|
}
|
|
});
|
|
|
|
return route += '/';
|
|
};
|
|
|
|
export default function () {
|
|
let path = window.location.pathname;
|
|
let subdir = path.substr(0, path.search('/ghost/'));
|
|
let adminRoot = `${subdir}/ghost/`;
|
|
let assetRoot = `${subdir}/ghost/assets/`;
|
|
let apiRoot = `${subdir}/ghost/api/v2/admin`;
|
|
|
|
function assetUrl(src) {
|
|
return subdir + src;
|
|
}
|
|
|
|
return {
|
|
adminRoot,
|
|
assetRoot,
|
|
apiRoot,
|
|
subdir,
|
|
blogRoot: `${subdir}/`,
|
|
count: 'https://count.ghost.org/',
|
|
|
|
url: {
|
|
admin() {
|
|
return makeRoute(adminRoot, arguments);
|
|
},
|
|
|
|
api() {
|
|
return makeRoute(apiRoot, arguments);
|
|
},
|
|
|
|
join() {
|
|
if (arguments.length > 1) {
|
|
return makeRoute(arguments[0], Array.prototype.slice.call(arguments, 1));
|
|
} else if (arguments.length === 1) {
|
|
let [arg] = arguments;
|
|
return arg.slice(-1) === '/' ? arg : `${arg}/`;
|
|
}
|
|
return '/';
|
|
},
|
|
|
|
asset: assetUrl
|
|
}
|
|
};
|
|
}
|