0
votes

I'm using ember-cli-simple-auth and the cookie-store add-on, I've set up my application and login routes and my authenticated routes, pretty much all that is working, but if I reload the page, or if livereload does it for me, I get kicked back out to the login page, have to enter credentials, and then get brought back to the page I was on. I thought this wasn't supposed to happen given what the docs say:

Ember Simple Auth persists the session state so it survives page reloads.

https://github.com/simplabs/ember-simple-auth

What should I look for to fix this?

Edit: adding cookie that's set after authenticating

cookie name: ember_simple_auth:session

%7B%22authenticator%22%3A%22authenticator%3Acustom%22%2C%22auth_token%22%3A%226hxR0eEL0EbHjPpfWFmdiWfKqHXLfXdYqG9wdZKgnlh3BacNvd41OHl6aOLFAv5C%22%2C%22account_id%22%3A%22A461225%22%2C%22full_name%22%3A%22Jess%20Hines%22%7D

EDIT This issue is similar, so looks like what I really need is help writing the restore() function.

1
Can you post the contents of the Ember Simple Auth cookie after you log in?marcoow
Added. I've just got three values: auth_token, account_id, and full_name (since I want to use that for some updates)redOctober13
Did you implement your custom authenticator's restore method correctly?marcoow
@marcoow, apparently not. pchoo was gracious enough to help me tremendously in writing the authenticator and authorizer, but I don't see a restore method in the authenticator. I've been reading everything I can find, but I didn't see anything about it in the README or the simplelabs page.redOctober13

1 Answers

0
votes

Examples provided by @marcoow on this github issue.

Here is my restore function:

restore: function(data) {
  return new Ember.RSVP.Promise(function(resolve, reject) {
    if (!Ember.isEmpty(data)) {
      resolve(data);
    } else {
      reject();
    }
  });
}