0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-08 02:52:39 -05:00

Refactored away CurrentUserSettings mixin (#2200)

no issue

Mixins are deprecated in Ember so we want to remove their usage. The `CurrentUserSettings` mixin was used in Route files to provide `transitionAuthor()` (that also transitions contributors) and `transitionEditor()` methods so the the consuming route could use them to prevent access to authors/editors. In practice the only reason this was used was to prevent access to admin-only routes.

- added an `AdminRoute` class that inherits from our `AuthenticatedRoute` class
  - when any route inherits from this class it will only allow access to admins and owners, any other user will be redirected to the home screen (dashboard or site depending on permissions)
- updated all of our admin-only routes to use the new `AdminRoute`
  - allowed for removal of `CurrentUserSettings` mixin usage
  - allowed for `beforeModel()` hooks to be removed from consuming routes in many cases
  - some admin-only routes were extending/inheriting directly from Ember's `Route` based on the assumption that the router hierarchy would have a parent route perform the redirect. Those have also been switched to `AdminRoute` for consistency and to prevent accidentally making them available if the router hierarchy changes
  - `/#/settings` does not use the `AdminRoute` so that it can redirect to the current user's setting page for non-admin users
- removed `CurrentUserSettings` mixin file
- cleaned up unnecessary computed property and function used for redirect-when-disabled in the Zapier route
This commit is contained in:
Kevin Ansfield 2022-01-17 10:05:27 +00:00 committed by GitHub
parent 7aec5667a1
commit 683a8584ce
42 changed files with 148 additions and 256 deletions

View file

@ -1,15 +0,0 @@
import Mixin from '@ember/object/mixin';
export default Mixin.create({
transitionAuthor(user) {
if (user.isAuthorOrContributor) {
return this.transitionTo('settings.staff.user', user);
}
},
transitionEditor(user) {
if (user.isEditor) {
return this.transitionTo('settings.staff');
}
}
});

View file

@ -0,0 +1,14 @@
import AuthenticatedRoute from './authenticated';
import {inject as service} from '@ember/service';
export default class AdminRoute extends AuthenticatedRoute {
@service session;
beforeModel() {
super.beforeModel(...arguments);
if (!this.session.user.isAdmin) {
return this.transitionTo('home');
}
}
}

View file

@ -1,8 +1,8 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import AdminRoute from 'ghost-admin/routes/admin';
import {action} from '@ember/object';
import {inject as service} from '@ember/service';
export default class MembersRoute extends AuthenticatedRoute {
export default class MembersRoute extends AdminRoute {
@service router;
_requiresBackgroundRefresh = true;
@ -14,13 +14,6 @@ export default class MembersRoute extends AuthenticatedRoute {
});
}
beforeModel() {
super.beforeModel(...arguments);
if (!this.session.user.isAdmin) {
return this.transitionTo('home');
}
}
model(params) {
this._requiresBackgroundRefresh = false;

View file

@ -1,7 +1,7 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import AdminRoute from 'ghost-admin/routes/admin';
import {inject as service} from '@ember/service';
export default class MembersRoute extends AuthenticatedRoute {
export default class MembersRoute extends AdminRoute {
@service store;
@service feature;
@ -13,14 +13,9 @@ export default class MembersRoute extends AuthenticatedRoute {
filterParam: {refreshModel: true}
};
// redirect to posts screen if:
// - TODO: members is disabled?
// - logged in user isn't owner/admin
beforeModel() {
super.beforeModel(...arguments);
if (!this.session.user.isAdmin) {
return this.transitionTo('home');
}
// - TODO: redirect if members is disabled?
}
model(params) {

View file

@ -1,3 +1,3 @@
import Route from '@ember/routing/route';
import AdminRoute from 'ghost-admin/routes/admin';
export default class MembersImportRoute extends Route {}
export default class MembersImportRoute extends AdminRoute {}

View file

@ -1,8 +1,8 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import AdminRoute from 'ghost-admin/routes/admin';
import {action} from '@ember/object';
import {inject as service} from '@ember/service';
export default class OffersRoute extends AuthenticatedRoute {
export default class OffersRoute extends AdminRoute {
@service router;
_requiresBackgroundRefresh = true;
@ -14,13 +14,6 @@ export default class OffersRoute extends AuthenticatedRoute {
});
}
beforeModel() {
super.beforeModel(...arguments);
if (!this.session.user.isAdmin) {
return this.transitionTo('home');
}
}
model(params) {
this._requiresBackgroundRefresh = false;

View file

@ -1,7 +1,7 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import AdminRoute from 'ghost-admin/routes/admin';
import {inject as service} from '@ember/service';
export default class offersRoute extends AuthenticatedRoute {
export default class offersRoute extends AdminRoute {
@service store;
@service feature;
@ -9,14 +9,9 @@ export default class offersRoute extends AuthenticatedRoute {
type: {refreshModel: true}
};
// redirect to posts screen if:
// - TODO: members is disabled?
// - logged in user isn't owner/admin
beforeModel() {
super.beforeModel(...arguments);
if (!this.session.user.isAdmin) {
return this.transitionTo('home');
}
// TODO: redirect if members is disabled?
}
model(params) {

View file

@ -1,10 +1,16 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
import {inject as service} from '@ember/service';
export default AuthenticatedRoute.extend({
session: service(),
export default AuthenticatedRoute.extend(CurrentUserSettings, {
beforeModel() {
this._super(...arguments);
this.transitionAuthor(this.session.user);
this.transitionEditor(this.session.user);
const user = this.session.user;
if (!user.isAdmin) {
return this.transitionTo('settings.staff.user', user);
}
}
});

View file

@ -1,16 +1,9 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
import AdminRoute from 'ghost-admin/routes/admin';
import {inject as service} from '@ember/service';
export default AuthenticatedRoute.extend(CurrentUserSettings, {
export default AdminRoute.extend({
settings: service(),
beforeModel() {
this._super(...arguments);
this.transitionAuthor(this.session.user);
this.transitionEditor(this.session.user);
},
model() {
return this.settings.reload();
},

View file

@ -1,7 +1,7 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import AdminRoute from 'ghost-admin/routes/authenticated';
import {inject as service} from '@ember/service';
export default class SettingsDesignRoute extends AuthenticatedRoute {
export default class SettingsDesignRoute extends AdminRoute {
@service customThemeSettings;
@service feature;
@service modals;
@ -9,14 +9,6 @@ export default class SettingsDesignRoute extends AuthenticatedRoute {
@service themeManagement;
@service ui;
beforeModel() {
super.beforeModel(...arguments);
if (!this.session.user.isAdmin) {
return this.transitionTo('site');
}
}
model() {
// background refresh of preview
// not doing it on the 'index' route so that we don't reload going to/from the index,

View file

@ -1,8 +1,8 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import AdminRoute from 'ghost-admin/routes/admin';
import {action} from '@ember/object';
import {inject as service} from '@ember/service';
export default class ChangeThemeRoute extends AuthenticatedRoute {
export default class ChangeThemeRoute extends AdminRoute {
@service store;
model() {

View file

@ -1,9 +1,9 @@
import Route from '@ember/routing/route';
import AdminRoute from 'ghost-admin/routes/admin';
import {action} from '@ember/object';
import {bind} from '@ember/runloop';
import {inject as service} from '@ember/service';
export default class InstallThemeRoute extends Route {
export default class InstallThemeRoute extends AdminRoute {
@service modals;
@service router;

View file

@ -1,7 +1,7 @@
import Route from '@ember/routing/route';
import AdminRoute from 'ghost-admin/routes/admin';
import {inject as service} from '@ember/service';
export default class ViewThemeRoute extends Route {
export default class ViewThemeRoute extends AdminRoute {
@service modals;
themeModal = null;

View file

@ -1,18 +1,11 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
import AdminRoute from 'ghost-admin/routes/admin';
import RSVP from 'rsvp';
import {inject as service} from '@ember/service';
export default AuthenticatedRoute.extend(CurrentUserSettings, {
export default AdminRoute.extend({
config: service(),
settings: service(),
beforeModel() {
this._super(...arguments);
this.transitionAuthor(this.session.user);
this.transitionEditor(this.session.user);
},
model() {
return RSVP.hash({
settings: this.settings.reload(),

View file

@ -1,8 +1,7 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
import AdminRoute from 'ghost-admin/routes/admin';
import {inject as service} from '@ember/service';
export default AuthenticatedRoute.extend(CurrentUserSettings, {
export default AdminRoute.extend({
router: service(),
init() {
@ -16,12 +15,6 @@ export default AuthenticatedRoute.extend(CurrentUserSettings, {
});
},
beforeModel() {
this._super(...arguments);
this.transitionAuthor(this.session.user);
this.transitionEditor(this.session.user);
},
model(params, transition) {
// use the integrations controller to fetch all integrations and pick
// out the one we want. Allows navigation back to integrations screen

View file

@ -1,6 +1,6 @@
import Route from '@ember/routing/route';
import AdminRoute from 'ghost-admin/routes/admin';
export default Route.extend({
export default AdminRoute.extend({
model(params) {
let integration = this.modelFor('settings.integration');
let webhook = integration.webhooks.findBy('id', params.webhook_id);

View file

@ -1,6 +1,6 @@
import Route from '@ember/routing/route';
import AdminRoute from 'ghost-admin/routes/admin';
export default Route.extend({
export default AdminRoute.extend({
model() {
let integration = this.modelFor('settings.integration');
return this.store.createRecord('webhook', {integration});

View file

@ -1,16 +1,9 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
import AdminRoute from 'ghost-admin/routes/admin';
import {inject as service} from '@ember/service';
export default AuthenticatedRoute.extend(CurrentUserSettings, {
export default AdminRoute.extend({
settings: service(),
beforeModel() {
this._super(...arguments);
this.transitionAuthor(this.session.user);
this.transitionEditor(this.session.user);
},
setupController(controller) {
// kick off the background fetch of integrations so that we can
// show the screen immediately

View file

@ -1,14 +1,11 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
import AdminRoute from 'ghost-admin/routes/admin';
import {inject as service} from '@ember/service';
export default AuthenticatedRoute.extend(CurrentUserSettings, {
export default AdminRoute.extend({
settings: service(),
beforeModel() {
this._super(...arguments);
this.transitionAuthor(this.session.user);
this.transitionEditor(this.session.user);
return this.settings.reload();
},

View file

@ -1,14 +1,11 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
import AdminRoute from 'ghost-admin/routes/admin';
import {inject as service} from '@ember/service';
export default AuthenticatedRoute.extend(CurrentUserSettings, {
export default AdminRoute.extend({
settings: service(),
beforeModel() {
this._super(...arguments);
this.transitionAuthor(this.session.user);
this.transitionEditor(this.session.user);
return this.settings.reload();
},

View file

@ -1,8 +1,8 @@
import Route from '@ember/routing/route';
import AdminRoute from 'ghost-admin/routes/admin';
import {action} from '@ember/object';
import {inject as service} from '@ember/service';
export default class NewIntegrationRoute extends Route {
export default class NewIntegrationRoute extends AdminRoute {
@service limit;
@service modals;

View file

@ -1,14 +1,11 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
import AdminRoute from 'ghost-admin/routes/admin';
import {inject as service} from '@ember/service';
export default AuthenticatedRoute.extend(CurrentUserSettings, {
export default AdminRoute.extend({
settings: service(),
beforeModel() {
this._super(...arguments);
this.transitionAuthor(this.session.user);
this.transitionEditor(this.session.user);
return this.settings.reload();
},

View file

@ -1,14 +1,11 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
import AdminRoute from 'ghost-admin/routes/admin';
import {inject as service} from '@ember/service';
export default AuthenticatedRoute.extend(CurrentUserSettings, {
export default AdminRoute.extend({
settings: service(),
beforeModel() {
this._super(...arguments);
this.transitionAuthor(this.session.user);
this.transitionEditor(this.session.user);
return this.settings.reload();
},

View file

@ -1,9 +1,7 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
import {computed} from '@ember/object';
import AdminRoute from 'ghost-admin/routes/admin';
import {inject as service} from '@ember/service';
export default AuthenticatedRoute.extend(CurrentUserSettings, {
export default AdminRoute.extend({
router: service(),
config: service(),
@ -17,16 +15,12 @@ export default AuthenticatedRoute.extend(CurrentUserSettings, {
});
},
disabled: computed('config.hostSettings.limits', function () {
return this.config.get('hostSettings.limits.customIntegrations.disabled');
}),
beforeModel() {
this._super(...arguments);
this.transitionDisabled();
this.transitionAuthor(this.session.user);
this.transitionEditor(this.session.user);
if (this.config.get('hostSettings.limits.customIntegrations.disabled')) {
return this.transitionTo('settings.integrations');
}
},
model(params, transition) {
@ -38,12 +32,6 @@ export default AuthenticatedRoute.extend(CurrentUserSettings, {
.integrationModelHook('slug', 'zapier', this, transition);
},
transitionDisabled() {
if (this.get('disabled')) {
this.transitionTo('settings.integrations');
}
},
buildRouteInfoMetadata() {
return {
titleToken: 'Zapier'

View file

@ -1,17 +1,10 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
import AdminRoute from 'ghost-admin/routes/admin';
import {inject as service} from '@ember/service';
export default AuthenticatedRoute.extend(CurrentUserSettings, {
export default AdminRoute.extend({
settings: service(),
notifications: service(),
beforeModel() {
this._super(...arguments);
this.transitionAuthor(this.session.user);
this.transitionEditor(this.session.user);
},
model() {
return this.settings.reload();
},

View file

@ -1,17 +1,13 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
import AdminRoute from 'ghost-admin/routes/admin';
import {inject as service} from '@ember/service';
export default AuthenticatedRoute.extend(CurrentUserSettings, {
export default AdminRoute.extend({
notifications: service(),
settings: service(),
beforeModel(transition) {
this._super(...arguments);
this.transitionAuthor(this.session.user);
this.transitionEditor(this.session.user);
if (transition.to.queryParams?.fromAddressUpdate === 'success') {
this.notifications.showAlert(
`Newsletter email address has been updated`,

View file

@ -1,16 +1,9 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import AdminRoute from 'ghost-admin/routes/admin';
import {inject as service} from '@ember/service';
export default class MembershipSettingsRoute extends AuthenticatedRoute {
export default class MembershipSettingsRoute extends AdminRoute {
@service settings;
beforeModel() {
super.beforeModel(...arguments);
if (!this.session.user.isAdmin) {
return this.transitionTo('home');
}
}
model() {
this.settings.reload();
}

View file

@ -1,17 +1,11 @@
import $ from 'jquery';
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
import AdminRoute from 'ghost-admin/routes/admin';
import RSVP from 'rsvp';
import {inject as service} from '@ember/service';
export default AuthenticatedRoute.extend(CurrentUserSettings, {
export default AdminRoute.extend({
settings: service(),
beforeModel() {
this._super(...arguments);
this.transitionAuthor(this.session.user);
},
model() {
return RSVP.hash({
settings: this.settings.reload()

View file

@ -1,8 +1,8 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import AdminRoute from 'ghost-admin/routes/admin';
import {action} from '@ember/object';
import {inject as service} from '@ember/service';
export default class ProductRoute extends AuthenticatedRoute {
export default class ProductRoute extends AdminRoute {
@service store
@service router;
@ -23,13 +23,6 @@ export default class ProductRoute extends AuthenticatedRoute {
}
}
beforeModel() {
super.beforeModel(...arguments);
if (!this.session.user.isAdmin) {
return this.transitionTo('home');
}
}
setupController(controller, product) {
super.setupController(...arguments);
if (this._requiresBackgroundRefresh) {

View file

@ -1,7 +1,7 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import AdminRoute from 'ghost-admin/routes/admin';
import {inject as service} from '@ember/service';
export default class ProductsRoute extends AuthenticatedRoute {
export default class ProductsRoute extends AdminRoute {
@service store
buildRouteInfoMetadata() {

View file

@ -1,8 +1,7 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
import {inject as service} from '@ember/service';
export default AuthenticatedRoute.extend(CurrentUserSettings, {
export default AuthenticatedRoute.extend({
infinity: service(),
session: service(),

View file

@ -1,8 +1,7 @@
/* eslint-disable camelcase */
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
export default AuthenticatedRoute.extend(CurrentUserSettings, {
export default AuthenticatedRoute.extend({
model(params) {
return this.store.queryRecord('user', {slug: params.user_slug, include: 'count.posts'});
},

View file

@ -1,10 +1,10 @@
/* eslint-disable camelcase */
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
import {inject as service} from '@ember/service';
export default AuthenticatedRoute.extend(CurrentUserSettings, {
export default AuthenticatedRoute.extend({
router: service(),
session: service(),
_requiresBackgroundRefresh: true,
@ -17,7 +17,10 @@ export default AuthenticatedRoute.extend(CurrentUserSettings, {
beforeModel() {
this._super(...arguments);
this.transitionAuthor(this.session.user);
if (this.session.user.isAuthorOrContributor) {
return this.transitionTo('home');
}
},
model(params) {

View file

@ -1,8 +1,7 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
import ShortcutsRoute from 'ghost-admin/mixins/shortcuts-route';
export default AuthenticatedRoute.extend(CurrentUserSettings, ShortcutsRoute, {
export default AuthenticatedRoute.extend(ShortcutsRoute, {
queryParams: {
type: {
refreshModel: true,
@ -23,7 +22,9 @@ export default AuthenticatedRoute.extend(CurrentUserSettings, ShortcutsRoute, {
beforeModel() {
this._super(...arguments);
this.transitionAuthor(this.session.user);
if (this.session.user.isAuthorOrContributor) {
return this.transitionTo('home');
}
},
// set model to a live array so all tags are shown and created/deleted tags

View file

@ -22,34 +22,34 @@ describe('Acceptance: Settings - Integrations - AMP', function () {
expect(currentURL(), 'currentURL').to.equal('/signin');
});
it('redirects to staff page when authenticated as contributor', async function () {
it('redirects to home page when authenticated as contributor', async function () {
let role = this.server.create('role', {name: 'Contributor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/integrations/amp');
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects to staff page when authenticated as author', async function () {
it('redirects to home page when authenticated as author', async function () {
let role = this.server.create('role', {name: 'Author'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/integrations/amp');
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects to staff page when authenticated as editor', async function () {
it('redirects to home page when authenticated as editor', async function () {
let role = this.server.create('role', {name: 'Editor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/integrations/amp');
expect(currentURL(), 'currentURL').to.equal('/settings/staff');
expect(currentURL(), 'currentURL').to.equal('/site');
});
describe('when logged in', function () {

View file

@ -22,14 +22,14 @@ describe('Acceptance: Settings - Code-Injection', function () {
expect(currentURL(), 'currentURL').to.equal('/signin');
});
it('redirects to staff page when authenticated as contributor', async function () {
it('redirects to home page when authenticated as contributor', async function () {
let role = this.server.create('role', {name: 'Contributor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/code-injection');
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects to staff page when authenticated as author', async function () {
@ -39,17 +39,17 @@ describe('Acceptance: Settings - Code-Injection', function () {
await authenticateSession();
await visit('/settings/code-injection');
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects to staff page when authenticated as editor', async function () {
it('redirects to home page when authenticated as editor', async function () {
let role = this.server.create('role', {name: 'Editor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/code-injection');
expect(currentURL(), 'currentURL').to.equal('/settings/staff');
expect(currentURL(), 'currentURL').to.equal('/site');
});
describe('when logged in', function () {

View file

@ -18,34 +18,34 @@ describe('Acceptance: Settings - General', function () {
expect(currentURL(), 'currentURL').to.equal('/signin');
});
it('redirects to staff page when authenticated as contributor', async function () {
it('redirects to home page when authenticated as contributor', async function () {
let role = this.server.create('role', {name: 'Contributor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/general');
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects to staff page when authenticated as author', async function () {
it('redirects to home page when authenticated as author', async function () {
let role = this.server.create('role', {name: 'Author'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/general');
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects to staff page when authenticated as editor', async function () {
it('redirects to home page when authenticated as editor', async function () {
let role = this.server.create('role', {name: 'Editor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/general');
expect(currentURL(), 'currentURL').to.equal('/settings/staff');
expect(currentURL(), 'currentURL').to.equal('/site');
});
describe('when logged in', function () {

View file

@ -22,34 +22,34 @@ describe('Acceptance: Settings - Integrations - Custom', function () {
expect(currentURL(), 'currentURL').to.equal('/signin');
});
it('redirects /integrations/ to staff page when authenticated as contributor', async function () {
it('redirects /integrations/ to home page when authenticated as contributor', async function () {
let role = this.server.create('role', {name: 'Contributor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/integrations');
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects /integrations/ to staff page when authenticated as author', async function () {
it('redirects /integrations/ to home page when authenticated as author', async function () {
let role = this.server.create('role', {name: 'Author'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/integrations');
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects /integrations/ to staff page when authenticated as editor', async function () {
it('redirects /integrations/ to home page when authenticated as editor', async function () {
let role = this.server.create('role', {name: 'Editor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/integrations/1');
expect(currentURL(), 'currentURL').to.equal('/settings/staff');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects /integrations/:id/ to signin when not authenticated', async function () {
@ -59,34 +59,34 @@ describe('Acceptance: Settings - Integrations - Custom', function () {
expect(currentURL(), 'currentURL').to.equal('/signin');
});
it('redirects /integrations/:id/ to staff page when authenticated as contributor', async function () {
it('redirects /integrations/:id/ to home page when authenticated as contributor', async function () {
let role = this.server.create('role', {name: 'Contributor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/integrations/1');
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects /integrations/:id/ to staff page when authenticated as author', async function () {
it('redirects /integrations/:id/ to home page when authenticated as author', async function () {
let role = this.server.create('role', {name: 'Author'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/integrations/1');
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects /integrations/:id/ to staff page when authenticated as editor', async function () {
it('redirects /integrations/:id/ to home page when authenticated as editor', async function () {
let role = this.server.create('role', {name: 'Editor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/integrations/1');
expect(currentURL(), 'currentURL').to.equal('/settings/staff');
expect(currentURL(), 'currentURL').to.equal('/site');
});
});

View file

@ -20,34 +20,34 @@ describe('Acceptance: Settings - Labs', function () {
expect(currentURL(), 'currentURL').to.equal('/signin');
});
it('redirects to staff page when authenticated as contributor', async function () {
it('redirects to home page when authenticated as contributor', async function () {
let role = this.server.create('role', {name: 'Contributor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/labs');
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects to staff page when authenticated as author', async function () {
it('redirects to home page when authenticated as author', async function () {
let role = this.server.create('role', {name: 'Author'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/labs');
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects to staff page when authenticated as editor', async function () {
it('redirects to home page when authenticated as editor', async function () {
let role = this.server.create('role', {name: 'Editor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/labs');
expect(currentURL(), 'currentURL').to.equal('/settings/staff');
expect(currentURL(), 'currentURL').to.equal('/site');
});
describe('when logged in', function () {

View file

@ -19,34 +19,34 @@ describe('Acceptance: Settings - Integrations - Slack', function () {
expect(currentURL(), 'currentURL').to.equal('/signin');
});
it('redirects to staff page when authenticated as contributor', async function () {
it('redirects to home page when authenticated as contributor', async function () {
let role = this.server.create('role', {name: 'Contributor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/integrations/slack');
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects to staff page when authenticated as author', async function () {
it('redirects to home page when authenticated as author', async function () {
let role = this.server.create('role', {name: 'Author'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/integrations/slack');
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects to staff page when authenticated as editor', async function () {
it('redirects to home page when authenticated as editor', async function () {
let role = this.server.create('role', {name: 'Editor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/integrations/slack');
expect(currentURL(), 'currentURL').to.equal('/settings/staff');
expect(currentURL(), 'currentURL').to.equal('/site');
});
describe('when logged in', function () {

View file

@ -22,34 +22,34 @@ describe('Acceptance: Settings - Integrations - Unsplash', function () {
expect(currentURL(), 'currentURL').to.equal('/signin');
});
it('redirects to staff page when authenticated as contributor', async function () {
it('redirects to home page when authenticated as contributor', async function () {
let role = this.server.create('role', {name: 'Contributor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/integrations/unsplash');
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects to staff page when authenticated as author', async function () {
it('redirects to home page when authenticated as author', async function () {
let role = this.server.create('role', {name: 'Author'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/integrations/unsplash');
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects to staff page when authenticated as editor', async function () {
it('redirects to home page when authenticated as editor', async function () {
let role = this.server.create('role', {name: 'Editor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/integrations/unsplash');
expect(currentURL(), 'currentURL').to.equal('/settings/staff');
expect(currentURL(), 'currentURL').to.equal('/site');
});
describe('when logged in', function () {

View file

@ -21,34 +21,34 @@ describe('Acceptance: Settings - Integrations - Zapier', function () {
expect(currentURL(), 'currentURL').to.equal('/signin');
});
it('redirects to staff page when authenticated as contributor', async function () {
it('redirects to home page when authenticated as contributor', async function () {
let role = this.server.create('role', {name: 'Contributor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/integrations/zapier');
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects to staff page when authenticated as author', async function () {
it('redirects to home page when authenticated as author', async function () {
let role = this.server.create('role', {name: 'Author'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/integrations/zapier');
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
expect(currentURL(), 'currentURL').to.equal('/site');
});
it('redirects to staff page when authenticated as editor', async function () {
it('redirects to home page when authenticated as editor', async function () {
let role = this.server.create('role', {name: 'Editor'});
this.server.create('user', {roles: [role], slug: 'test-user'});
await authenticateSession();
await visit('/settings/integrations/zapier');
expect(currentURL(), 'currentURL').to.equal('/settings/staff');
expect(currentURL(), 'currentURL').to.equal('/site');
});
describe('when logged in', function () {