1
I’m starting a web system and it will be multi-tenant, I want to do using the firebase database, but not yet I found a way to associate a user to a tenant (company) so that he has access only to the tree of that company. I use the following method to create a user and authenticate it:
// Criar novo usuário
createUserButton.addEventListener('click', function () {
firebase
    .auth()
    .createUserWithEmailAndPassword(emailInput.value, passwordInput.value, passwordId.value)
    .then(function () {
        alert('Bem vindo ' + emailInput.value);
    })
    .catch(function (error) {
        console.error(error.code);
        console.error(error.message);
    });
});
// Autenticar com E-mail e Senha
authEmailPassButton.addEventListener('click', function () {
firebase
    .auth()
    .signInWithEmailAndPassword(emailInput.value, passwordInput.value)
    .then(function (result) {
        console.log(result);
        displayName.innerText = 'Bem vindo, ' + emailInput.value;
        alert('Autenticado ' + emailInput.value);
    })
    .catch(function (error) {
        console.error(error.code);
        console.error(error.message);            
    });
});
Now my question is how do I add personalized information to a user like the company ID so that they only have access to what they are allowed to do.
I noticed that you are a beginner in Firebase. I recommend that you read the documentation from the Realtime Database
– Rosário Pereira Fernandes