jeudi 12 juillet 2018

Ember Simple Auth: 'authorize' is deprecated. [deprecation id: ember-simple-auth.session.authorize]

In fact, I get two warnings. I'll describe the script in order.

At the time of authorization (GraphQL mutation), I don't receive a warning. Requests to receive anything (for example, a list of posts) without authorization - also without warning. But when I successfully logged in, all requests are accompanied by two warnings:

The first:

DEPRECATION: Ember Simple Auth: 'authorize' is deprecated. [deprecation id: ember-simple-auth.session.authorize] See https://github.com/simplabs/ember-simple-auth#authorizers for more details.

And the second:

DEPRECATION: Ember Simple Auth: Authorizers are deprecated in favour of setting headers directly. [deprecation id: ember-simple-auth.baseAuthorizer] See https://github.com/simplabs/ember-simple-auth#deprecation-of-authorizers for more details.

I collected all my code from their repository.

app/authorizers/custom.js:

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

export default Base.extend({
  session: service(),

  authorize(sessionData, block) {
    const { email, token } = sessionData
    block('X-User-Email', email)
    block('X-User-Token', token)
  }
})

Part of the code from app/authenticators/custom.js file:

restore(data) {
  return new RSVP.Promise((resolve, reject) => {
    if (!isEmpty(data.token)) {
      resolve(data)
    } else {
      reject()
    }
  })
},

Authorization works. The server receives data in each request.

But these warnings do not allow me to live normally. They appear only in development mode. In the production application (from dist) there are none.




Aucun commentaire:

Enregistrer un commentaire