Ember Simple Auth: Session lost on refresh

前端 未结 4 782
孤城傲影
孤城傲影 2021-01-02 05:35

I\'m using Ember Simple Auth Devise v 0.6.4 in an Ember-cli app.

I can log in fine but when I refresh the page the session is lost. (Tested in Firefox and Chrome.) <

4条回答
  •  余生分开走
    2021-01-02 06:07

    I had this issue as well. It turns out that the restore method in the authenticator did not take into account the resource name.

    In particular, changing the line indicated here: https://github.com/simplabs/ember-simple-auth/blob/master/packages/ember-simple-auth-devise/lib/simple-auth-devise/authenticators/devise.js#L95

    as follows:

    if (!Ember.isEmpty(propertiesObject.get(_this.resourceName)[_this.tokenAttributeName]) && !Ember.isEmpty(propertiesObject.get(_this.resourceName)[_this.identificationAttributeName])) {
    

    solved the problem.

    Note that my local storage looked like:

    {"secure":{"authenticator":"simple-auth-authenticator:devise","user":{"id":1,"email":"test@gmail.com","created_at":"2015-07-20T22:30:47.966Z","updated_at":"2015-07-23T17:45:41.874Z","authentication_token":"7Uv6LysQ2h3x-P4WUMmU","token":"7Uv6LysQ2h3x-P4WUMmU"}}}
    

    As a result, this required the additional changes in the config/environment.js

      ENV['simple-auth-devise'] = {
        identificationAttributeName: 'email',
        resourceName: 'user',
        tokenAttributeName: 'authentication_token',
        crossOriginWhitelist: ['*']   
      };
    

    Changing bower_components/ember-simple-auth/simple-auth-devise.amd.js is what allowed me to see that this indeed was my problem.

提交回复
热议问题