roughing in custom session (again :( )

This commit is contained in:
Matthew Dillon 2015-07-09 20:52:01 -08:00
parent bb2386807c
commit 72c957f8dc
7 changed files with 42 additions and 10 deletions

View file

@ -1,7 +1,17 @@
import Ember from 'ember';
import ApplicationRouteMixin from 'simple-auth/mixins/application-route-mixin';
// import parseBase64 from '../../utils/parse-base64';
export default Ember.Route.extend(ApplicationRouteMixin, {
// model: function() {
// let token = this.get('session.secure.token');
// if (Ember.isNone(token)) {
// return null;
// }
// let user = parseBase64(token);
// return this.store.find('user', user.sub);
// },
actions: {
invalidateSession: function() {
this.get('session').invalidate().then(() => {

View file

@ -2,7 +2,8 @@ import Ember from 'ember';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
export default Ember.Route.extend(AuthenticatedRouteMixin, {
beforeModel: function() {
beforeModel: function(transition) {
this._super(transition);
this.transitionTo('compare');
}
});

View file

@ -11,13 +11,7 @@ export default Ember.Controller.extend({
this.set('loading', true);
// Manually clean up because there might not be a transition
this.get('flashMessages').clearMessages();
session.authenticate(authenticator, credentials).then(()=>{
this.set('loading', false);
let t = parseBase64(session.get('secure.token'));
this.store.find('user', t['sub']).then((user) => {
session.set('currentUser', user);
});
}, (error)=> {
session.authenticate(authenticator, credentials).then(null, (error)=> {
this.set('loading', false);
this.get('flashMessages').error(error.error);
});

View file

@ -2,7 +2,8 @@ import Ember from 'ember';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
export default Ember.Route.extend(AuthenticatedRouteMixin, {
beforeModel: function() {
beforeModel: function(transition) {
this._super(transition);
if (this.get('session.currentUser.role') === 'R') {
this.transitionTo('species.index');
}

View file

@ -2,7 +2,8 @@ import Ember from 'ember';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
export default Ember.Route.extend(AuthenticatedRouteMixin, {
beforeModel: function() {
beforeModel: function(transition) {
this._super(transition);
if (this.get('session.currentUser.role') === 'R') {
this.transitionTo('strains.index');
}