Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release a version compatible with ESA v3.1.0 #297

Closed
gwak opened this issue Feb 4, 2021 · 5 comments · Fixed by #299
Closed

Release a version compatible with ESA v3.1.0 #297

gwak opened this issue Feb 4, 2021 · 5 comments · Fixed by #299
Assignees
Labels

Comments

@gwak
Copy link

gwak commented Feb 4, 2021

Hi,

We're currently migrating our app off of mixins. We have used ember-simple-auth with ember-simple-auth-token successfully in the past.
Now that ember-simple-auth has released the final v3.1.0 version, is there a compatible version of ember-simple-auth-token in the works ?
If not, is it feasible soon ?

Thanks

@fenichelar
Copy link
Owner

@gwak while I have not personally tested it yet, I don't see any reason you can't use the latest version of ember-simple-auth-token with ember-simple-auth@3.1.0. Are you running into any issues?

@fenichelar fenichelar self-assigned this Feb 4, 2021
@edprats
Copy link

edprats commented Feb 26, 2021

I'm experiencing the same issue, for me its mostly that the "DataAdapterMixin" is deprecated which is causing lots of warnings in the new versions.

https://github.com/simplabs/ember-simple-auth/blob/master/guides/upgrade-to-v3.md#refactor-ember-data-adapters-to-remove-use-of-authorizers

@fenichelar
Copy link
Owner

fenichelar commented Feb 26, 2021

The ember-simple-auth-token mixins use the DataAdapterMixin. But you don't need to use the supplied mixins and probably shouldn't. With Octance, mixins aren't considering a good practice.

I have not had an opportunity to add text to the readme to describe how to use ember-simple-auth-token without the provided mixins. But the ember-simple-auth readme provides the information needed. Basically, do this in you adapter:

import { inject } from '@ember/service';
import { computed } from '@ember/object';
import DS from 'ember-data';

export default DS.RESTAdapter.extend({
  session: inject('session'),

  headers: computed('session.isAuthenticated', 'session.data.authenticated.token', function() {
    if (this.session.isAuthenticated) {
      return {
        Authorization: `Bearer ${this.session.data.authenticated.token}`,
      };
    } else {
      return {};
    }
  }),

  handleResponse(status) {
    if (status === 401 && this.session.isAuthenticated) {
      this.session.invalidate();
    }
    return this._super(...arguments);
  },
});

@edprats
Copy link

edprats commented Feb 26, 2021

Thank you, I was able to remove the token mixin use with this.

@fenichelar
Copy link
Owner

I have updated the documentation: #299

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants