dimanche 7 février 2016

Ember.js - How can I save data to session from authenticator?

I have tried doing this.get('session') but it gives me nothing.

I want to save data to my session

I only seem to get the information I need from the authenticator but can't seem to be able to pass it around. (Tried a couple of methods suggested on SO but none seem to be able to work from the autheticator)

import Ember from 'ember';
  import Torii from 'ember-simple-auth/authenticators/torii';

  const { service } = Ember.inject;

  export default Torii.extend({
    torii: service('torii'),
    authenticate(options) {
      return this._super(options).then(function (data) {
        console.log(data);
      });
    }
  });

Caller of the autheticator (Is the info I need accessible from here already?)

import Ember from 'ember';

export default Ember.Controller.extend({
   session: Ember.inject.service('session'),
    actions: {
      authenticateSession() {
        this.get('session').authenticate('authenticator:torii', 'google-token');
      },
      invalidateSession() {
        this.get('session').invalidate();
      }
    }
});

Aucun commentaire:

Enregistrer un commentaire