My question is how to do so that the identifier of a user record is the same in email and when saving data is by the same identifier all this I am doing in html and javascript the code is as follows:
var database = firebase.database();
var userConect = null;
var Nombre = document.getElementById('nombre').value;
var Apellido = document.getElementById('apellido').value;
var Edad = document.getElementById('edad').value;
function registro(){
firebase.auth().createUserWithEmailAndPassword(email, password)
.then(function() {
console.log('OK');
})
So here is the code to create the account by email
This part is the listener
function observador() {
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
console.log('Ya hay un usuario activo');
// User is signed in.
var displayName = user.displayName;
var email = user.email;
console.log(user.emailVerified);
var emailVerified = user.emailVerified;
var uid = user.uid;
userConect = database.ref("users");
AgregarDB(user.uid, user.emailVerified, Nombre, Apellido, Edad);
function AgregarDB(Nombre,Apellido, Edad) {
var Nombre = document.getElementById('nombre').value;
var Apellido = document.getElementById('apellido').value;
var Edad = document.getElementById('edad').value;
var conectados = userConect.push({
uid: uid,
emailVerified: emailVerified,
Nombre: Nombre,
Apellido: Apellido,
Edad: Edad
});
}
}
All this is the code and insert images for a better understanding of my question
image 1
image 2
I want the key image of the push (DB) to be the same as image 1 (user registration by email) key of the user record