lundi 25 janvier 2016

how to get session data created by auth0 in ember 2.3

I am using ember 2.3 (and ember-data 2.3); I'm setting up a simple user auth process using Auth0. Nothing fancy yet, just installed auth0 according to :

http://ift.tt/1OLRvl4

Now, my setup is pretty much exactly the same as the project given here. However, it seems that I can only access the session from application.hbs and not any other template. Or route. Or anything else.

So this handlebars snippet:

{{#if session.isAuthenticated}}
  {{session.data.authenticated.profile.name}}
{{else}}
  NOPE
{{/if}}

works on application.hbs but nowhere else. This does not make sense to me; if auth0 itself says that session.data can be accessed from any template, and that such a handlebars snippet even exists, there must be something I'm missing. I need to be able to show certain portions of the client side as well as restrict some actions based on the currently signed-in user (and whether someone is actually signed in ), all of which are included in the session.data object.

It doesn't seem appropriate to pass this object to every component I'm going to create, and the only way I can think of getting this data right now is to manually get it from localStorage. I could perhaps make this manual process a mixin and have it included everywhere but before I try to find roundabout solutions, I want to make sure that I'm not missing something in the implementation itself.

How would I be able to access the session token throughout the application aside from application.hbs itself?




Aucun commentaire:

Enregistrer un commentaire