mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 01:42:29 +03:00
cf7a763199
refs https://github.com/TryGhost/Admin/pull/1901 Ember has deprecated mixins in preparation for 4.0 and `ember-simple-auth` has now done the same in 3.1.0. - removed all imports of Ember Simple Auth mixins - moved authenticated and invalidated handling from application route to session service - moved server-notification loading from application route to session service - updated `AuthenticatedRoute` to use the session service directly rather than authenticated route mixin - added `UnauthenticatedRoute` that incorporates the behaviour from our overridden `UnauthenticatedRouteMixin` and switches to using the session service directly
39 lines
966 B
JavaScript
39 lines
966 B
JavaScript
import AjaxServiceSupport from 'ember-ajax/mixins/ajax-support';
|
|
import RESTAdapter from '@ember-data/adapter/rest';
|
|
import ghostPaths from 'ghost-admin/utils/ghost-paths';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default RESTAdapter.extend(AjaxServiceSupport, {
|
|
host: window.location.origin,
|
|
namespace: ghostPaths().apiRoot.slice(1),
|
|
|
|
session: service(),
|
|
|
|
shouldBackgroundReloadRecord() {
|
|
return false;
|
|
},
|
|
|
|
query(store, type, query) {
|
|
let id;
|
|
|
|
if (query.id) {
|
|
id = query.id;
|
|
delete query.id;
|
|
}
|
|
|
|
return this.ajax(this.buildURL(type.modelName, id), 'GET', {data: query});
|
|
},
|
|
|
|
buildURL() {
|
|
// Ensure trailing slashes
|
|
let url = this._super(...arguments);
|
|
let parsedUrl = new URL(url);
|
|
|
|
if (!parsedUrl.pathname.endsWith('/')) {
|
|
parsedUrl.pathname += '/';
|
|
}
|
|
|
|
return parsedUrl.toString();
|
|
}
|
|
});
|