firebase sign up with additional details for authentication - firebase-realtime-database

I am creating sign up page with firebase so i want to users firstname and lastname we can do with real time database but i do not understand how to do with exact uid as user sign up uid using set keyword can you please guide me to create this.
Here is code snippet i am trying

Related

How to add the username,telephone number with password in Firebase?

I'm using Firebase and I'm trying to add a username,telephone number, the database with the password.
s there a way to do it or is createUserWithEmailAndPassword() function only for email and password?
Given the method name createUserWithEmailAndPassword, it would seem that is creates a user with an email and a password.
There is nothing built into Firebase to create a user based on a user name as phone number. The two most common approaches are:
Use an existing Firebase identity provider to create a user based on for example the phone number, and then store the additional information in the database associated with that user.
Create your own identity provider that does precisely what you want.

Firebase forgot password- how to identify whether user signed in with email or facebook?

This is my scenario. I am developing a firebase login iOS app. For this i am using Email & Password Authentication and facebook authentication. Lets assume if user knows his email but forgot the password. How can i identify if the user logged in with facebook or email, and how to reset the password? i searched a lot. But could not find a solution for that. can anyone help me.
You can lookup the providers linked to an account using:
fetchProvidersForEmail
To reset the password, use: sendPasswordResetWithEmail
There are also instructions on how to send the password reset and redirect back to app:
https://firebase.google.com/docs/auth/ios/passing-state-in-email-actions
Try the following.
Whenever a user signs up with your platform, be sure to save their basic information e.g. email, name, photoURL, signup/loginType, user-id etc to a database of your choice i.e Firebase Firestore or the Realtime Database(RTD).
So you could have the following Scheme in the RTD for instance:
my-app
----users
--------user-id-1
------------name: User 1
------------email: user1#domain.com
------------loginType:facebook
------------id: user-id-1
--------user-id-2
------------name: User 2
------------email: user2#domain.com
------------loginType:email
------------id: user-id-2
---etc
This way if a user claims to have forgotten their password, you can do a quick lookup via email and obtain the users id. For the Realtime Database I would recommend denormalize your data a bit more so that you can retrieve user id's by email. This is what I mean
my-app
--users
--------user-id-1
------------name: User 1
------------email: user1#domain.com
------------id: user-id-1
--------user-id-2
------------name: User 2
------------email: user2#domain.com
------------loginType:email
------------id: user-id-2
--users-by-email
--------user1#domain.com
------------user-id-1
--------user2#domain.com
------------user-id-2
In this case you can easily find the users id based on their email if you search the users-by-email field and insert the users email as a key. It should return the userid.
In Firestore, I believe you can easily query for this without having to denormalize your data.
Once you have access to the users-id and email, you can follow this guide by #JenPerson from the Firebase team on how to mint your own Authentication tokens, that will let Firebase know you are re-authenticating a specified user with different credentials

Users Sync between Firebase Custom Auth and existing app and users database

The company I work for has a production ROR web application that handles user authentication using devise on backend. I´ve been asked to develop a mobile app using specific IONIC 3 with firebase template, This app works along with existing ROR web app and I cannot modify backend auth, so I implemented Firebase´s Custom Token authentication and had it to work. For testing purposes I registered manually user accounts in Firebase console using existing username and uids on my baackend, but when I try to login using a user account that is not manually registered, I get the following exception "there is no user record corresponding to this identifier" I know it is because there is no user wit that uid in firebase, but reading the documentation I found here it says "...After a user signs in for the first time, a new user account is created and linked to the credentials—that is, the user name and password, phone number, or auth provider information—the user signed in with. This new account is stored as part of your Firebase project, and can be used to identify a user across every app in your project, regardless of how the user signs in...." so my question is, Is there a way to have firebase register users automatically after using SigninWithCustomToken? Can anyone advise on a correct flow to achieve sync between current back end and firebase users?
I´ve never used firebase before and have not found more than very basic documentation.
Thanks in advance.

Password for Facebook Login with Parse in Objective C?

I am using PFUser to save registration details of users in Parse including password.
But, When I use Facebook SDK to login, how handle no password case ? Because, we don't get a password from Facebook SDK and we don't need to have one for Single Sign On Login with Facebook. But, PFUser must expecting the password to store and I can't fill it with empty string. Because, many people can try with Email and Empty password which can login the user.
NOTE : I am not using the PFFacebookUtils class of Parse and I don't want to use it even.
Could someone help me by explaining the solution for it ?
When you authenticate a Facebook user with Parse, it creates an Auth token that Facebook uses. The AuthData can be found in the "authData" column in your _User class.
I'm doing the same thing in my app and it works nicely.

if I add SSO for both facebook and Gmail then should I treat users who login from both with same email id as new user?

I have created facebook sso and it works perfect.I am getting the email id as one of the unique factor in my server db .So it treats the user who has logged in the first time as new user and after submitting the form with extra info as already existing user.
I was thinking of adding gmail sso but my query is if the user in gmail with the same email id as the one he used to enter facebook account is already existing then should I treat him as existing user or new user as the email id is unique and already exists in the server db.
Or remove email id as the unique factor in the above case or just check if the user is signing in from facebook/gmail and then do the further verifications ? Please help me out with this .
Any help or link for the above query would help me a great deal.I would really appreciate any help.
Thanks in Advance.
I would say just allow the email to be the unique id. If user uses the same email for both accounts so be it. Many users of all social medias use one email to connect to all of their accounts.

Resources