Skip to content

Instantly share code, notes, and snippets.

@planetexpress69
Created November 3, 2016 14:13
Show Gist options
  • Save planetexpress69/2f0bf925fe468a1d3c5ac9adde61fd6a to your computer and use it in GitHub Desktop.
Save planetexpress69/2f0bf925fe468a1d3c5ac9adde61fd6a to your computer and use it in GitHub Desktop.
session.attemptedTransition
//Route (AuthenticatedRouteMixin)
init: function() {
this._super(...arguments);
},
beforeModel(transition) {
if (!this.get('session.isAuthenticated')) {
let authenticationRoute = "login";
this.set('session.attemptedTransition', transition);
Ember.Logger.info(this.get('session')); // <== session contains the attempteTransition
return this.transitionTo(authenticationRoute);
} else {
return this._super(...arguments);
}
},
//Login controller
authenticate() {
let {identification, password} = this.getProperties('identification', 'password');
var _this = this;
this.get('session').authenticate('authenticator:oauth2', identification, password).then((response) => {
Ember.Logger.info(_this.get('session.attemptedTransition')); // <== null :-(
this.transitionToRoute('index.index');
})
.catch((reason) => {
this.set('errorMessage', reason.error_description || reason);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment