Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

215
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda