Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!