Re: [Firebase] .on + auth/unauth

72 views
Skip to first unread message

Michael Lehenbauer

unread,
Jan 28, 2013, 12:25:06 PM1/28/13
to fireba...@googlegroups.com
Hey Patrick,
  1. You should auth() before doing any operations that depend on being authenticated, else they'll be rejected.  So if the data isn't publicly accessible, you'll want to auth() and then do your on('child_added').
  2. When you unauth(), any on() registrations that are no longer permitted will be canceled.  You can be notified of this using the cancelCallback to .on().
  3. We'll soon be adding an API so you can globally monitor auth state.  It's not implemented yet, but it'll look something like this:

    new Firebase(myFirebase).child('.info/authenticated').on(function(authSnap) {
      if (authSnap.val() === true) { /* I'm authenticated! */ } else { /* I'm not authenticated. */ }
    });
Hope that helps,
-Michael

On Sun, Jan 27, 2013 at 8:47 PM, Patrick Williams <pwmc...@gmail.com> wrote:
If I do something like `ref.on('child_added')`, then authenticate using auth/login after, will it behave the same as if I set the 'child_added' callback after the authentication? Also, if I call unauth, will I receive 'child_removed' events (or a 'value' event with a null-ish value)? If not, is there a way to listen for unauth events so that I can trigger the cleanup of the children manually?

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To post to this group, send email to fireba...@googlegroups.com.
 
 

Patrick Williams

unread,
Jan 28, 2013, 4:30:06 PM1/28/13
to fireba...@googlegroups.com
That sounds great. Looking forward to it.
Reply all
Reply to author
Forward
0 new messages