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?
The error is that it seems EmberFire as of yet does not support a validation child rule. Most probably because it's trying to update the cart before the item is inserted.
This was working in Ember 1.7 and a previous version of EmberFire.
The rule-block below that does work, with the part that did not work uncommented: