Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
question(auth): sign in anonymously on application starup #137
I am trying to add an onAuthStateChanged listener to the firebase object when using reactReduxFirebase. The docs here describe that this parameters should set that value.
My assumption is like in the tutorial here
onAuthStateChanged will get called on appStartup w/ the current user or an undefined user (which in my code will trigger an anonymous login). My goal is to make my app by default be an anonymously logged in user. Is something wrong with my approach here? Is this feature supposed to work as I have described?
// Firebase config
// react-redux-firebase options
const FirebaseStore = reactReduxFirebase(firebaseConfig, config);
// Eventually store is created like this
Based on your code, this is expected behavior (the
This means that the tutorial you have posted will not work.
It seems like you are attempting to sign in anonymously on application start. If that is the case you will want to be checking to see if auth exists on that boot not when auth changes.
You would most likely want to place the sign in anonymously code into a home page component. That page can check auth, redirecting somewhere if it exists, and bringing you to a login page if not. That login page can handle the signing in anonymously.
All of that said, just to make things more clear, this may be added as a feature in the future, but will be breaking for some.
@radicalnerds Yes, it is a deviation.
That said, when that decision was made, this use case was not understood. One of the goals of this library is to keep compatibility with Firebase across the board, so this is for sure a good idea for a change.
Thanks for pointing it out. This issue will be updated when/if this is changed.
added a commit
May 23, 2017
As stated, this may become the standard functionality, but it has remained disabled by default for now to keep new