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
30 lines
800 B
JavaScript
30 lines
800 B
JavaScript
import Route from '@ember/routing/route';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default class UnauthenticatedRoute extends Route {
|
|
@service ajax;
|
|
@service ghostPaths;
|
|
@service session;
|
|
|
|
beforeModel() {
|
|
let authUrl = this.ghostPaths.url.api('authentication', 'setup');
|
|
|
|
// check the state of the setup process via the API
|
|
return this.ajax.request(authUrl).then((result) => {
|
|
let [setup] = result.setup;
|
|
|
|
if (setup.status !== true) {
|
|
this.transitionTo('setup');
|
|
} else {
|
|
return this.session.prohibitAuthentication('home');
|
|
}
|
|
});
|
|
}
|
|
|
|
buildRouteInfoMetadata() {
|
|
return {
|
|
bodyClasses: ['unauthenticated-route']
|
|
};
|
|
}
|
|
}
|