I have manually imported JSON file for the database with the following users:
{
"users": {
"Naseebullah": {
"name": "Naseebullah Ahmadi",
"gender": "Male",
"type": "Patient",
"Doctors": ["Ernest"],
"age": "20",
"DOB": "02/06/1997",
"address": "122 Atherstone Court",
"contactNumber": "07473693312",
"emailAddress": "[email protected]",
"profilePicture": "../Images/profile.jpg",
"ECG": [0, 0, 0, 0, 0.0000050048828125, 0.0000137939453125],
"HeartSound": [0, 0, 0, 0, 0.0000050048828125, 0.0000137939453125]
},
"Ernest": {
"name": "Ernest Kamavuako",
"gender": "Male",
"type": "Doctor",
"Patients": ["Naseebullah"],
"age": "30",
"DOB": "20/12/1970",
"address": "122 Harrow Street",
"contactNumber": "07473033312",
"emailAddress": "[email protected]",
"profilePicture": "../Images/profile.jpg",
"ECG": [""],
"HeartSound": [""]
}
}
}
and I have manually created two users for authentication:
The issue is when I log in as "Naseebullah" ([email protected]), I don't receive his details:
"Naseebullah": {
"name": "Naseebullah Ahmadi",
"gender": "Male",
"type": "Patient",
"Doctors": ["Ernest"],
"age": "20",
"DOB": "02/06/1997",
"address": "122 Atherstone Court",
"contactNumber": "07473693312",
"emailAddress": "[email protected]",
"profilePicture": "../Images/profile.jpg",
"ECG": [0, 0, 0, 0, 0.0000050048828125, 0.0000137939453125],
"HeartSound": [0, 0, 0, 0, 0.0000050048828125, 0.0000137939453125]
},
In other words, I don't get his name, gender and so on...
This is where I authenticate:
const onLogin = creds => {
const { email, password } = creds;
//console.log("props123 ", values, nav);
firebase.auth().signInWithEmailAndPassword(email, password).then((user) => {
console.log("user: ", user);
/*
* User is logged in
*
* */
}).catch(err => {
const { code,message } = err;
console.log("not loggedin, ", message);
});
};
How can I retrieve the user's details from the database when the user is authenticated with email and password?
email
is common in your auth and database. so first get the email from auth and then query users who has the specific email and display the data. – Hareesh