lundi 30 novembre 2015

Ember-Simple-Auth and Torii

I am having a problem in connecting ember-simple-auth and torii in order to do a facebook authentication.

I have in my config/environment.js:

torii: {
  providers: {
    'facebook-oauth2': {
      apiKey: 'my_api_key'      
    }
  }
}

package.json:

"ember-simple-auth": "1.0.1",
"torii": "0.6.1"

controllers/application.js:

import Ember from 'ember';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';

export default Ember.Controller.extend(ApplicationRouteMixin, {
    session: Ember.inject.service('session'),
    torii: Ember.inject.service(),
    actions: {
        authenticateWithFacebook: function(){
          this.get('session').authenticate(
            'simple-auth-authenticator:torii',
            'facebook-oauth2'
          ).then(
            function(data) {
              alert('SUCCESS ' + data);
            },
            function(error) {
              alert('There was an error when trying to sign you in: ' + error);
            }
          );
        }
    }   
});

app/authenticators/torii.js:

import ToriiAuthenticator from 'ember-simple-auth/authenticators/torii';

export default ToriiAuthenticator.extend({
  torii: Ember.inject.service()
});

Although I can connect with facebook using just torii, this example fails with the following error:

Uncaught Error: Assertion Failed: No authenticator for factory "simple-auth-authenticator:torii" could be found!

Any ideas? I use the latest ember-cli version.




Aucun commentaire:

Enregistrer un commentaire