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

225
Views
Vue - Show registration form for new authenticated users with firebase

I have a Vue app where is implemented firebase as BaaS. To check when the user is authenticated I'm using the onAuthStateChanged method that is provided out of the box from firebase, but it's giving me a problem.

In detail, I'm checking if an user never logged in to the app using an auth provider and registered into the RTDB database by compiling the form, by checking the authResult.additionalUserInfo.isNewUser that is provided from the callback of firebase UI, but this have a downside that I need to fix.

In fact I'm not able to show the registration form after success callback is called also if the isNewUser condition is true because when onAuthStateChanged is called and the user isn't null it will ignore my if() stetement. I'm using this method to show the firebase ui and manage this condition:

        showFirebaseLoginUI() {
            fbui.start(this.$refs.firebaseWidget, {
                signInOptions: [
                    firebase.auth.EmailAuthProvider.PROVIDER_ID,
                    firebase.auth.GoogleAuthProvider.PROVIDER_ID,
                    firebase.auth.TwitterAuthProvider.PROVIDER_ID,
                    firebase.auth.FacebookAuthProvider.PROVIDER_ID,
                ],
                callbacks: {
                    signInSuccessWithAuthResult: (authResult) => {
                        console.log(authResult)
                        if( authResult.additionalUserInfo.isNewUser ){
                            console.log('New user')
                            this.showWizard = true
                        } else {
                            this.$router.push({ name: 'Home' })
                        }
                    }
                },
                signInFlow: 'popup'
            });
        }

The console log will be displayed, but wizard will not and the user will be redirected directly to the homepage

    created() {
        onAuthStateChanged(getAuth(app), (user) => {
            if( user && !this.showWizard ){
                this.$router.push({ name: 'Home' })
            } 
        })
    }

Since I need to add the user to the database after he add some information and when an user is already logged avoid that the login page will be displayed, how I can fix this?

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