Fixing Ember Simple Auth Deprecation Warnings

I’ve taken over an Ember application and most of my work to date is getting the codebase up to date. I’ve come across an issue with Ember Simple Auth. I’m getting the following deprecation warnings:

  • Ember Simple Auth: Authorizers are deprecated in favour of setting headers directly. and

  • Ember Simple Auth: 'authorize' is deprecated.

I’ve been reading the documentation on the deprecation on the Github project, but I’m still not sure how to migrate away from it effectively. I attempted to remove my custom authorizer by commenting out its authorize function, but now login functionality doesn’t work at all.

This GitHub issue says to replace any instance where the custom authorizer is being used with something like this: this.get(''); However, the only places I see my custom authorizer being used are being injected as a service into adapters/applicaiton.js and environment.js

This is what my customer authorizer looks like

// project/app/authorizers/custom.js

import { inject as service } from '@ember/service';
import Base from 'ember-simple-auth/authorizers/base';
import Ember from 'ember';

export default Base.extend({
  session: service(),
  authorize(data, block) {
    if (Ember.testing) {
      block('Authorization', 'something');

    const { token } = data;

    if (this.get('session.isAuthenticated') && token) {
      block('Authorization', `Bearer ${token}`);
1 Like