I am writing an ember app (using ember 2.3.0) using emberfire & torii for authentication. After a user logs in, their uid is available to me in the torii session
object. I also have a user
model and would like to access other data related to the current user in my templates, routes, etc.
I can get this to work in a single route by doing something like:
let uid = this.get('session').get('uid');
this.store.findRecord('user', uid).then(user => {
console.log(user.get('firstName'));
});
but would like to prevent having to write this for each route/controller that needs to access it.
Could anyone advise on the best way to do this? Is the best way to use a service? If so, how can I ensure that the code in my service is executed after my session object is available?
Aucun commentaire:
Enregistrer un commentaire