I have integrated firebaseui-web in my current app but I'm facing an issue in case of singing in with email.
As of right now the flow is -
"Sign in with email"
1) If you try it first time than it will prompt you for a username. That's good.
2) Than, It'll ask you to fill your full name and password. That's also good.
3) But, when you hit the submit button, you can access the progress only in signInSuccess().
I have a problem with the third step above because right now I'm also hitting my api to save the user info on server side and it is not giving any such call back in documentation which handles the flow after sign up instead of it can only handle the flow in signInSuccess().
Is there any way with which I can catch the submit event here?
Or Is there any property which tells me that this is the first attempt of login after signup by user?
Please feel free to ask If you need any further information to reproduce or understand the issue.
@gauravt1, coud you explain a bit more why using signInSuccess does not fit your need? Is it becasue you want a callback only for new account creations?
@nicolasgarnier, Yes I want a callback for new account creation. Actually, I need to save the user info on server as well on creation of account in firebase. Is it possible to do so?
I don't think there is such callback with Firebaseui.
@bojeil-google this could be an interesting feature request, at least for email+password.
@gauravt1 if you are only using email+password it is possible to do it if you are not going to use firebaseui. Using the Core Firebase auth SDK you would do:
firebase.auth().createUserWithEmailAndPassword(email, password).then(user => {
// Account has been created here.
})
Alternatively you can use Cloud Functions. There is a callback/event specifically for new account creation. That will allow you to automatically trigger server-side code that respond to user-creation events. See: https://firebase.google.com/docs/functions/auth-events This might be a very good option for you.
@nicolasgarnier Do I need to install "firebase-admin" and "firebase-tools" and integrate them with the app?
For Cloud Fucntions? Yes. The easiest is to run firebase init functions and this will add a functions directory with a sample Cloud Function in it.
Here is also a sample app that's sending a "Welcome" email to new users upon account creation: https://github.com/firebase/functions-samples/tree/master/quickstarts/email-users
For a client side solution, Firebase Auth now returns additional metadata on sign in/up which can help determine if a user is new or existing: https://firebase.google.com/support/release-notes/js#4.6.0
We plant to also return that to the developer soon. For now, you can check currentUser metadata and compare last sign in time with creation time to determine if a user is new or returning.
I think this should definitely be added to FirebaseUI. My sign in works perfectly, but I store additional user information in the database and when a new account is created, my app crashes due to nil values. I need to know when a new user is created so I can prompt them to enter the additional info.
I also think this saves us quite a lot of hassle with account creation. I currently have to check the DB for an existing user, create, fetch data again etc etc. It would be much easier if the returned payloads include additionalUserInfo and the newUser property 馃憣
Most helpful comment
For a client side solution, Firebase Auth now returns additional metadata on sign in/up which can help determine if a user is new or existing: https://firebase.google.com/support/release-notes/js#4.6.0
We plant to also return that to the developer soon. For now, you can check currentUser metadata and compare last sign in time with creation time to determine if a user is new or returning.