jeudi 1 septembre 2016

EmberJS: global class functions depend on a session variable, using Ember-Simple-Auth. Best Practice?

I had a question regarding best practice when it comes to building a global utility class in EmberJS when the class will exhibit user-specific behavior.

The following conditions are all true:

  1. The class's methods could be accessed from anywhere in the entire application.
  2. The application performs JSON based authentication using Ember-Simple-Auth.
  3. The authentication confirmation payload comes with some information about the user.
  4. The information received in the token payload will determine the behavior of the utility class's function.

My Questions

  1. Is a Util the best option? Should I be using services and somehow "initialize" this service on a confirmed authentication? My end goal is to use this class from almost every route/template/component in my application.

  2. How chill are authentication payloads? Is it OK to send crumbs of user specific information information in the authentication payload in addition to any tokens?




Aucun commentaire:

Enregistrer un commentaire