vendredi 11 décembre 2015

ember-simple-auth session restore not working

I have a custom authenticator which is really just extending the oauth2 authenticator so I can pass additional infomration to the API with my POST to /token.

All works fine. However, when you do a page refresh and the session tries to restore I am redirected to the login page and not authenticated.

The restore() method, if still within expiry and has a token should and does resolve with data however this does not authenticate the session.

Any ideas?

restore: function(data) {
var _this = this;
return new Ember.RSVP.Promise(function(resolve, reject) {
  var now = (new Date()).getTime();
  if (!Ember.isEmpty(data.expires_at) && data.expires_at < now) {
    if (_this.refreshAccessTokens) {
      _this.refreshAccessToken(data.expires_in, data.refresh_token).then(function(data) {
        resolve(data);
      }, reject);
    } else {
      reject();
    }
  } else {
    if (Ember.isEmpty(data.access_token)) {
      reject();
    } else {
      _this.scheduleAccessTokenRefresh(data.expires_in, data.expires_at, data.refresh_token);
      Ember.run(function() {
        log('returning restore')
        log(data) //shows my previous session data including access_token
        resolve(data);
      })
    }
  }
});
},




Aucun commentaire:

Enregistrer un commentaire