We're trying to authenticate with a customToken to Firebase - this has been working before we moved to EmberCLI as we initiated these Firebase specific adapters at a later stage in the app runtime.
Now trying to initiate the authCustomToken at an earlier stage in the adapter with the flow as follows:
- Initiate adapter
- Hook on "init" and request a token from backend
- When token received - authWithCustomToken
Code looks pretty much like this:
import DS from 'ember-data';
/**
* CartAdapter
* @class adapters.Cart
* @extends DS.FirebaseAdapter
*/
export default DS.FirebaseAdapter.extend(ajax, {
firebase: new Firebase('https://firebasehost.com'),
pathForType: function() {
return 'carts/' + this.get('sessionService').get('userId');
},
initAdapter: function() {
this.ajaxRequest('backendhost/firebase/').then(function(data) {
var ref = new Firebase('https://firebasehost.com');
ref.authWithCustomToken(data.token);
});
}.on('init')
});
How is the best way of approaching this?