Wait to load until currentUser returns
This commit is contained in:
parent
eb1a8bb6e3
commit
e36d327f36
12 changed files with 85 additions and 84 deletions
|
@ -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);
|
||||
},
|
||||
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
},
|
||||
|
||||
},
|
||||
|
|
|
@ -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');
|
||||
},
|
||||
|
||||
},
|
||||
|
|
|
@ -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);
|
||||
},
|
||||
|
||||
},
|
||||
|
|
|
@ -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');
|
||||
},
|
||||
|
||||
},
|
||||
|
|
3
app/pods/protected/template.hbs
Normal file
3
app/pods/protected/template.hbs
Normal file
|
@ -0,0 +1,3 @@
|
|||
{{#x-application invalidateSession="invalidateSession"}}
|
||||
{{outlet}}
|
||||
{{/x-application}}
|
Reference in a new issue