mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-20 09:22:49 +03:00
4d074c3e55
Closes #3291 - Adds redirects based on roles as defined in the case - Adds new mixin `CurrentUserSettings` - For authors, all settings pages redirect to `users/self` - For editors, all settings pages other than specific users redirect to `users`. Any user that is not self or an author redirects to `users`
38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
import {mobileQuery} from 'ghost/utils/mobile';
|
|
import CurrentUserSettings from 'ghost/mixins/current-user-settings';
|
|
|
|
var SettingsIndexRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, CurrentUserSettings, {
|
|
// redirect to general tab, unless on a mobile phone
|
|
beforeModel: function () {
|
|
var self = this;
|
|
this.currentUser()
|
|
.then(this.transitionAuthor())
|
|
.then(this.transitionEditor())
|
|
.then(function () {
|
|
if (!mobileQuery.matches) {
|
|
self.transitionTo('settings.general');
|
|
} else {
|
|
//fill the empty {{outlet}} in settings.hbs if the user
|
|
//goes to fullscreen
|
|
|
|
//fillOutlet needs special treatment so that it is
|
|
//properly bound to this when called from a MQ event
|
|
self.set('fillOutlet', _.bind(function fillOutlet(mq) {
|
|
if (!mq.matches) {
|
|
self.transitionTo('settings.general');
|
|
}
|
|
}, self));
|
|
mobileQuery.addListener(self.fillOutlet);
|
|
}
|
|
});
|
|
},
|
|
|
|
deactivate: function () {
|
|
if (this.get('fillOutlet')) {
|
|
mobileQuery.removeListener(this.fillOutlet);
|
|
}
|
|
}
|
|
});
|
|
|
|
export default SettingsIndexRoute;
|