lundi 16 octobre 2017

ember-simple-auth session.isAuthenticated is false after refresh page

I'm using ember-simple-auth with Cookie based authentication. When i login the is true, but when i reload the page this is FALSE, but the localStore didn't change.

This is my custom.js authenticator:

import Base from 'ember-simple-auth/authenticators/base';
import config from '../config/environment';

export default Base.extend({
    tokenEndpoint: config.apiUrl + '/user/signIn',
    restore(data) {      
      console.log(data);
      return RSVP.resolve(data);
    },
    authenticate(username, password) {
      return Ember.$.ajax({
          url: this.tokenEndpoint,
          type: 'POST',
          data: JSON.stringify({
            username: username,
            password: password,
          }),
          contentType: 'application/json;charset=utf-8',
          dataType: 'json',
      });

    },
    invalidate: function () {
      return Ember.RSVP.resolve();
    },
  });

I'm using the in the application.hbs. So i'm injecting the session in application controller:

session: Ember.inject.service('session')



Aucun commentaire:

Enregistrer un commentaire