GoogleWebComponents / firebase-element

Web components for the Firebase Web API
https://elements.polymer-project.org/elements/firebase-element
95 stars 72 forks source link

Firebase-collection not loading data after login #125

Closed wwalterego closed 8 years ago

wwalterego commented 8 years ago

Here is the situation:

read rules of the Firebase: ".read": "auth !== null && (auth.provider === 'google' || auth.provider === 'password')"

I have a custom element with a firebase-collection (with a bound dom-repeat to show data) and a firebase-auth that manages the login.

If you start the app and you're logged out, you correctly can't read the data. Then you log in but the collection doesn't show data after authentication. You have to reload the page to see the dom-repeat populated (of course it also works if you log in with redirect).

elements: <firebase-collection id="dataRef" location="{{location}}" data = "{{data}}"></firebase-collection>

<firebase-auth id="auth" provider="password"
                location="{{location}}"
                status-known="{{statusKnown}}"
                user="{{user}}"></firebase-auth>

<template is="dom-repeat" items="{{data}}" >
    <div>{{item.name}}</div></template> 

<paper-button on-tap="login" raised>log in</paper-button>

login: function(){ this.$.auth.login({email: 'email.email@gmail.com', password: 'password'}); }

am I missing something or is it a expected behaviour?

thanks in advance!

Walter Miani

johnlim commented 8 years ago

@wwalterego After your app has authenticated, nothing is triggering <firebase-collection> to make a query to firebase. If you take a look at https://github.com/PolymerLabs/todo-list as an example, the app has an observer on user and changes the location in <firebase-collection> which "triggers" a query to firebase, thus resulting in data being updated. Which is the behaviour you want.

As of now, this seems to be the expected behaviour unless someone comes along and improve it.

wwalterego commented 8 years ago

It totally worked for me! Thanks a lot @johnlim !