mardi 26 juillet 2016

Ember Data Firebase rules confusion

I'm getting started with my first Ember/Firebase application and having trouble finding documentation that goes beyond public data.

My goal is to have an application where signed in users can create and view their own data. I see that Firebase suggests this rule for such a situation:

{ "rules": { "users": { "$uid": { ".read": "$uid === auth.uid", ".write": "$uid === auth.uid" } } } }

But I can't find out any information about how this would work on the Ember end. For example, assuming I have an "entry" model that I am saving:

save(model) { model.save().then( () => { this.transitionToRoute('index'); }, error => { console.error(`error: ${error}`); }) },

Not sure if I need to be storing a uid in the model?

And then if I want the user to get a listing of their own entries:

import Ember from 'ember'; export default Ember.Route.extend({ model() { return this.store.findAll('entry'); } });

This produces the following error: ember.debug.js:30610 Error while processing route: index permission_denied at /entries: Client doesn't have permission to access the desired data. Error: permission_denied at /entries: Client doesn't have permission to access the desired data.

At this point I'm not sure what I should be doing –– do I need to build a custom URL or add a namespace in my firebase adapter to add a users/xxx prefix? Or etc?

Cannot find any documentation/tutorials/walkthroughs that cover anything beyond public read/write data.

Any advice appreciated.




Aucun commentaire:

Enregistrer un commentaire