Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
more ember-simple-auth UnauthenticatedRoute cleanup (#44)
Browse files Browse the repository at this point in the history
no issue
- aligns routes that require the user to be logged out with the ember-simple-auth method of doing things
  • Loading branch information
acburdine authored and kevinansfield committed Feb 10, 2017
1 parent 6f637e1 commit 7b0ed8c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions app/routes/reset.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import Route from 'ember-route';
import injectService from 'ember-service/inject';
import Configuration from 'ember-simple-auth/configuration';
import UnauthenticatedRouteMixin from 'ember-simple-auth/mixins/unauthenticated-route-mixin';
import styleBody from 'ghost-admin/mixins/style-body';

export default Route.extend(styleBody, {
export default Route.extend(styleBody, UnauthenticatedRouteMixin, {
classNames: ['ghost-reset'],

notifications: injectService(),
session: injectService(),

beforeModel() {
this._super(...arguments);
if (this.get('session.isAuthenticated')) {
this.get('notifications').showAlert('You can\'t reset your password while you\'re signed in.', {type: 'warn', delayed: true, key: 'password.reset.signed-in'});
this.transitionTo(Configuration.routeAfterAuthentication);
}

this._super(...arguments);
},

setupController(controller, params) {
Expand Down
9 changes: 4 additions & 5 deletions app/routes/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import {
} from 'ghost-admin/services/ajax';

import DS from 'ember-data';
import Configuration from 'ember-simple-auth/configuration';
import UnauthenticatedRouteMixin from 'ember-simple-auth/mixins/unauthenticated-route-mixin';
import styleBody from 'ghost-admin/mixins/style-body';

const {Promise} = RSVP;
const {Errors} = DS;

export default Route.extend(styleBody, {
export default Route.extend(styleBody, UnauthenticatedRouteMixin, {
classNames: ['ghost-signup'],

ghostPaths: injectService(),
Expand All @@ -24,12 +24,11 @@ export default Route.extend(styleBody, {
ajax: injectService(),

beforeModel() {
this._super(...arguments);

if (this.get('session.isAuthenticated')) {
this.get('notifications').showAlert('You need to sign out to register as a new user.', {type: 'warn', delayed: true, key: 'signup.create.already-authenticated'});
this.transitionTo(Configuration.routeIfAlreadyAuthenticated);
}

this._super(...arguments);
},

model(params) {
Expand Down

0 comments on commit 7b0ed8c

Please sign in to comment.