Firebase Auth redirection after login

Hi, I’m building my first integration of framework7, vue and firebase.

I’m not using vue-router, and I like to redirect my users after a success login to the home page.
Here’s is the code I’m trying in main app.js but is not working.

 methods: {
    onF7Ready(f7) {
        firebase.initializeApp(config);
        firebase.auth().onAuthStateChanged(function(user) {
            if (user){
                f7.views.create('#main-view', { url: '/home/' })
            } else {
                f7.views.create('#main-view', { url: '/login/' })
            }
        })
    },
  },

Any help would be very appreciated.

If your main view was already created then it should be:

f7.views.main.router.navigate('/home/')

or

f7.views.main.router.navigate('/login/')

Hi, Thanks for your answer, it works great!
Now I’m trying to redirect from the function below and I’m getting this error " ReferenceError: f7 is not defined".
I know this probably is a silly question but I dont know how to refer to f7 in this case.

Here’s the function:

 methods: {
  resetPassword: function() {
        firebase.auth().sendPasswordResetEmail(this.email).then(function(){
            alert('Reset email sent.')
            f7.views.main.router.navigate('/login/');
        }).catch(function(error){
            alert('Oops. ' + error)
        });
  }
}

Thanks for the help.

Means, f7 is not available in current JS scope. If it is a F7’s router component, then call it like this.$app.views.main.router.navigate('/login/')

Hi, Thanks again for the advise. This is my working solution

 methods: {
  resetPassword: function() {
      var that = this;
        firebase.auth().sendPasswordResetEmail(this.email).then(function(){
            alert('Reset email sent..')
            that.$f7.views.main.router.navigate('/login/')
        }).catch(function(error){
            alert('Oops. ' + error)
        });
  }
}