Wait to load until currentUser returns

This commit is contained in:
Matthew Dillon 2015-07-10 10:31:07 -08:00
parent eb1a8bb6e3
commit e36d327f36
12 changed files with 85 additions and 84 deletions

View file

@ -1,9 +1,12 @@
import Ember from 'ember';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
import parseBase64 from '../../utils/parse-base64';
export default Ember.Route.extend(AuthenticatedRouteMixin, {
model: function() {
let user = this.get('session.secure.currentUser');
console.log(user);
}
let token = this.get('session.secure.token');
let user = parseBase64(token);
return this.store.find('user', user.sub);
},
});

View file

@ -7,12 +7,12 @@ export default Ember.Controller.extend({
if (species.get('isDirty')) {
species.save().then((species) => {
this.transitionToRoute('species.show', species);
this.transitionToRoute('protected.species.show', species);
}, (err) => {
this.get('flashMessages').error(err.responseJSON.error);
});
} else {
this.transitionToRoute('species.show', species);
this.transitionToRoute('protected.species.show', species);
}
},
@ -22,7 +22,7 @@ export default Ember.Controller.extend({
species.get('errors').clear();
species.rollback();
this.transitionToRoute('species.show', species);
this.transitionToRoute('protected.species.show', species);
},
},

View file

@ -7,18 +7,18 @@ export default Ember.Controller.extend({
if (species.get('isDirty')) {
species.save().then((species) => {
this.transitionToRoute('species.show', species.get('id'));
this.transitionToRoute('protected.species.show', species.get('id'));
}, (err) => {
this.get('flashMessages').error(err.responseJSON.error);
});
} else {
species.deleteRecord();
this.transitionToRoute('species.index');
this.transitionToRoute('protected.species.index');
}
},
cancel: function() {
this.transitionToRoute('species.index');
this.transitionToRoute('protected.species.index');
},
},

View file

@ -7,23 +7,23 @@ export default Ember.Controller.extend({
if (strain.get('isDirty')) {
strain.save().then((strain) => {
this.transitionToRoute('strains.show', strain);
this.transitionToRoute('protected.strains.show', strain);
}, (err) => {
this.get('flashMessages').error(err.responseJSON.error);
});
} else {
strain.deleteRecord();
this.transitionToRoute('strains.show', strain);
this.transitionToRoute('protected.strains.show', strain);
}
},
cancel: function() {
let strain = this.get('strain');
let strain = this.get('protected.strain');
strain.get('errors').clear();
strain.rollback();
this.transitionToRoute('strains.show', strain);
this.transitionToRoute('protected.strains.show', strain);
},
},

View file

@ -7,17 +7,17 @@ export default Ember.Controller.extend({
if (strain.get('isDirty')) {
strain.save().then((strain) => {
this.transitionToRoute('strains.show', strain);
this.transitionToRoute('protected.strains.show', strain);
}, (err) => {
this.get('flashMessages').error(err.responseJSON.error);
});
} else {
this.transitionToRoute('strains.index');
this.transitionToRoute('protected.strains.index');
}
},
cancel: function() {
this.transitionToRoute('strains.index');
this.transitionToRoute('protected.strains.index');
},
},

View file

@ -0,0 +1,3 @@
{{#x-application invalidateSession="invalidateSession"}}
{{outlet}}
{{/x-application}}