lundi 2 novembre 2015

Ember-simple-auth custom authorizer not called

I'm trying to implement custom auth with ember-simple-auth and I stuck at the start. I have app/autheticators/digest.js

import Base from 'ember-simple-auth/authenticators/base';
import Ember from 'ember';

export default Base.extend({
  restore(data) {
    //
  },
  authenticate(email, password) {
    console.log(email, password);
    return new Ember.RSVP.Promise(function(resolve, reject) {
      Ember.run(function() {
          resolve({email: email, password: password});
        });
    });
  },
  invalidate(data) {
    //
  }
});

app/authorizers/digest.js

import Base from 'simple-auth/authorizers/base';  
import Ember from 'ember';

export default Base.extend({  
  header: function() {
    return "test-digest";
  },

  authorize: function(sessionData, block) {
    console.log('authorize...');
    block('Authorization', this.get('header'));
  }
});

Login component:

import Ember from 'ember';
import CryptoJS from 'npm:crypto-js';

export default Ember.Component.extend({
    session: Ember.inject.service('session'),
    actions: {
        login() {
            let { email, password } = this.getProperties('email', 'password');
            this.get("session").authenticate('autheticator:digest', 
                email, CryptoJS.SHA256(password).toString()).catch((reason) => {
                this.set('errorMessage', reason.error);
            });
        }
    }

});

Authentication called properly (I hope), but "authorize" in authorizer never called. I also tried add some values to ENV:

  ENV['simple-auth'] = {
    authorizer: 'authorizer:digest',
    crossOriginWhitelist: ['http://ift.tt/1M7cqvx'] // ['*'] I also tried
  }; 

But nothing changed. What I'm doing wrong?




Aucun commentaire:

Enregistrer un commentaire