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

131
Visualizações
Login still redirect to the same page even when using different email to log in

I'm using Firestore and Nuxt for my project.

I want my application to redirect the pages based on their user type when they are logged in.

I want if userType = contractor, when login it will redirect to /WPC/DashboardWPC. I want if userType = subcontractor, when login it will redirect to /Form/SectionA.

But currently, when logging in, it will always redirect to /Form/SectionA. I don't want that. I want it to log to different pages based on their user type.

Any advice?

    Login() {
      let credentials = {
        email: this.email,
        password: this.password,
      };
      this.$store
        .dispatch("user/Login", credentials)
        .then(() => {

          const users = firestore.collection('Users')

          users.get().then(() => {
            if (firestore.collection('Users').where("userType", "==", "subcontractor")) {
              window.location = "/Form/SectionA";
            } else if (firestore.collection('Users').where("userType", "==", "contractor")) {
              //console.log(snapshot.docs[0].data())
              window.location = "/WPC/DashboardWPC";
            } else {
              window.location = "/BWG/DashboardBWG";
            }
          })
      }).catch((err) => {
        alert(err.message)
      })
    }

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I am unsure how are you allowing your users to log in, but the signInWithEmailAndPassword is the method Firebase provides.

I have no experience with nuxt.js but something like this should give you a general idea:

Login() {
    firebase.auth().signInWithEmailAndPassword(this.email, this.password)
       .then((user) => {
            const _userDoc = firestore.collection('Users').doc(user.uid).get();
            const userType = _userDoc.data['userType'];
            if(userType == "subcontractor"){
                window.location = "/Form/SectionA";
            }
            else if(userType == "contractor"){
                window.location = "/WPC/DashboardWPC";
            }
            else{
                window.location = "/BWG/DashboardBWG";
            }
           
        },
        (err) => {
            alert(err.message);
        },
    );
}

Also, for registering your users you can use the createUserWithEmailAndPassword method.

about 4 years ago · Juan Pablo Isaza 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