lundi 1 mai 2017

How get token from ember-simple-auth-token to use with Websocket?

In my implementation below I try get the token from ember-simple-auth-token and use with a URL, used to connect with ActionCable:

...

export default Route.extend({
  store: service(),
  currentUser: service(),
  session: service(),
  cable: service(),

  setupConsumer: on('init', function() {
    let token = this.get('session.data.authenticated.jwt');
    let consumer = this.get('cable')
      .createConsumer(`http://ift.tt/2pPDkI0}`);

    let channelMixin = Mixin.create({
      received(data) {
        this.get('store').pushPayload(data);
      }
    });

    consumer.subscriptions.create({
      channel: 'ChatroomsChannel'
    }, channelMixin);
  }),

  ...
});

This works only at first request. I need store this in a cookie? Thanks.




Aucun commentaire:

Enregistrer un commentaire