Currently I have small project using react native and I am using Firebase as backend. I have registration form with more than two fields (name, phone num, gender, etc), but with Firebase we can only register a user with email and password. So, my question is how I can save other information of user and later how I would retrieve that information?
Asked
Active
Viewed 3,043 times
1
-
Since the email is unique, you can store other data on firebase database including the email. So once user is successfully signin, you can use the same email to fetch all necessary details from the firebase database (Cloud Firestore in this scenario) – Samitha Nanayakkara Jun 09 '20 at 11:57
-
The common approach is to store the additional information in a database, such as Cloud Firestore or the Realtime Database. See https://stackoverflow.com/q/42735452, https://stackoverflow.com/a/46657503 – Frank van Puffelen Jun 09 '20 at 12:54
1 Answers
3
On your backend you can create 'users' collection and save it after registering a user
const data = {
email: 'email',
password: 'password'
}
firebase.auth().createUser(data)
.then((userRecord) => {
var uid = userRecord.uid;
return firebase.firestore().collection('users').doc(uid)
.set({
user_uid: uid,
gender: '',
...
})
})
and later you can use doc id to retrieve extra information
firebase.firestore().collection('users').doc(uid).get()

test
- 2,429
- 15
- 44
- 81