Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

214
Visualizações
How can i seperate two types of users in firebase to seperate the login of web and mobile app users

I am currently working on a project where the parking lot owners should use website login and other users should use mobile app login. But currently any user can login into both of the website and mobile app.

here is my firebase realtime database my realtime database

So as you can see I defined type in user. when signing up a user gets a type depending on the device he/she registering

and my web sign in function is like this:

    signInWithEmailAndPassword(auth, email, password).then((userCredential) => {
    const user = userCredential.user;

    alert('User Logged in!');
    window.location = 'user.html';
}).catch((error) => {
    const errorCode = error.code;
    const errorMessage = error.message;
    alert(errorMessage);
});

How can I provide login for the users which have 'type = web' ?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Firebase Authentication only cares about credentials: if the email/password you enter matches the data in the system, you can sign in - no matter what platform you're on. There is no way to change this in Firebase Authentication, so any additional logic will have to come from your application code.

For example, you could store a list of the UIDs of the parking lot owners, and check against that after signing in to allow then to use the web app or not.

signInWithEmailAndPassword(auth, email, password).then((userCredential) => {
  const user = userCredential.user;

  if (user) {
    const uid = user.uid;                                  // determine the UID of the user
    const ownersRef = firebase.database().ref("parkinglotOwners");
    const userSnapshot = await ownersRef.child(uid).get(); // try to load this users data from parkinglotOwners
    if (userSnapshot.exists()) {                           // if this data exists
      window.location = 'user.html';                       // send them to the web app
    } else {
      alert("You're not allowed to use this app";          // tell them to go away
    }
  }

  ...
}).catch((error) => {
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda