mercredi 4 mai 2016

ember-simple-auth cookieExpirationTime not working

I need to implement a "remember me" feature in my application. I am using the built-in devise authenticator and have the following as my Session Store:

// app/session-stores/application.js
import CookieStore from 'ember-simple-auth/session-stores/cookie';

export default CookieStore.extend({
  cookieName: 'myapp-session-cookie'
});

I have a login-form component with the following:

rememberMe: false,
setExpirationTime() {
  const expirationTime = this.get('rememberMe') ? (14 * 24 * 60 * 60) : null;
  this.set('session.store.cookieExpirationTime', expirationTime);    
},

actions: {
  authenticateWithDevise() {
    this.setExpirationTime();
    let { identification, password } = this.getProperties('identification', 'password');
    this.get('session').authenticate('authenticator:devise', identification, password).then(() => {
      this.sendAction('onLoggedIn');
    }).catch((reason) => {
      this.set('errorMessage', reason.errors[0]);
    });
  }
}

and of course in the corresponding template I have:





What happens is session is never remembered, no matter whether cookieExpirationTime was set or null. My question is: should I also implement something else on the server side? I'm currently using devise's rememberable. Also, I've tried searching both here and on github but can only find conversations and code that seems obsolete, like this:

http://ift.tt/23qdxyC

Can somebody please shed some light? Thanks!




Aucun commentaire:

Enregistrer un commentaire