I'm having an issue with facebook authentication with the torii adapter, the error being: 'The Torii adapter must implement open
for a session to be opened'.
I've visited many tutorials, and tried all presented methods, but most of them are usually old ember code and none of them seem to actually work.
Current state: I am able to login, I get the facebook popup and I can authorize. Proof of this would be a route that I set to authenticatedRoute, that effectively disables after logging in. Strangely enough, however, my doesn't trigger.
Using fiddler, I can also see the response from the API containing a JSON response with all credentials from the user I authenticated with. In the firebase console, I can see the authorized user, reset its password, deny access,...
All this leads me to believe that it's 'merely' a front-end issue where I can't seem to establish a proper 'session' to work with.
My end goal would be to pick up the relevant user data and transfer it to my firebase backend as a 'user' entry, allowing for quick registration for site visitors, but I'll be more than glad to have an active session so I can work out the rest on my own.
As a front-end rookie (I normally code C#), Ember may not have been the best choice to get the hang it, but I'm this far now, I'm not about to let it all slide and pick up a different framework.
My code:
config/environment.js
firebase: {
apiKey: 'xxxxxxx',
authDomain: 'myappname.firebaseapp.com',
databaseURL: 'http://ift.tt/1sg9T8I',
storageBucket: 'myappname.appspot.com',
messagingSenderId: '1234567890'
},
torii: {
sessionServiceName: 'session'
}
torii-adapters/application.js (I've changed this so much, I can't even remember what the original code was, because none of what I change/add/delete here seems to do anything at all.)
export default Ember.Object.extend({
store: Ember.inject.service(),
open: function(authorization) {
var firstName = authorization.firstName,
store = this.get('store');
return store.find('user', firstName).then(function(user) {
return {
currentUser : user
};
});
}
});
routes/application.js
import Ember from 'ember';
export default Ember.Route.extend({
beforeModel: function() {
return this.get('session').fetch().catch(function() {
});
},
actions: {
login: function(provider) {
this.get('session').open('firebase', {
provider: provider,
}).then.transitionTo('about');
},
logout: function() {
this.get('session').close();
}
}
});
login.hbs
<div class="jumbotron text-center">
<a class="btn"></a>
</div>
<span>Currently logged in as with
- <a >Sign out</a></span>
Aucun commentaire:
Enregistrer un commentaire