2015-02-13 07:22:32 +03:00
import Ember from 'ember' ;
2015-10-18 21:17:02 +03:00
import Configuration from 'ember-simple-auth/configuration' ;
2014-03-10 07:44:08 +04:00
import styleBody from 'ghost/mixins/style-body' ;
2016-01-19 16:03:27 +03:00
const {
Route ,
inject : { service }
} = Ember ;
2015-10-28 14:36:45 +03:00
export default Route . extend ( styleBody , {
2014-03-31 13:57:50 +04:00
classNames : [ 'ghost-reset' ] ,
2014-10-25 01:09:50 +04:00
2016-01-19 16:03:27 +03:00
notifications : service ( ) ,
session : service ( ) ,
2015-05-26 05:10:50 +03:00
2015-10-28 14:36:45 +03:00
beforeModel ( ) {
2015-11-15 14:06:49 +03:00
this . _super ( ... arguments ) ;
2015-10-18 21:17:02 +03:00
if ( this . get ( 'session.isAuthenticated' ) ) {
2015-10-07 17:44:23 +03:00
this . get ( 'notifications' ) . showAlert ( 'You can\'t reset your password while you\'re signed in.' , { type : 'warn' , delayed : true , key : 'password.reset.signed-in' } ) ;
2015-05-13 08:27:59 +03:00
this . transitionTo ( Configuration . routeAfterAuthentication ) ;
2014-07-28 20:00:08 +04:00
}
} ,
2014-10-25 01:09:50 +04:00
2015-10-28 14:36:45 +03:00
setupController ( controller , params ) {
2014-03-31 13:57:50 +04:00
controller . token = params . token ;
2014-10-02 19:12:54 +04:00
} ,
2014-10-25 01:09:50 +04:00
2014-10-02 19:12:54 +04:00
// Clear out any sensitive information
2015-10-28 14:36:45 +03:00
deactivate ( ) {
this . _super ( ... arguments ) ;
2014-10-02 19:12:54 +04:00
this . controller . clearData ( ) ;
2014-03-31 13:57:50 +04:00
}
2014-03-10 07:44:08 +04:00
} ) ;