我这里有这段代码。
Router.beforeEach((to, from, next) => {
// AUTH = firebase.auth()
// it allows me to get the auth
// status of the user
AUTH.onAuthStateChanged(user => {
if (to.matched.some(m => m.meta.auth) && user) {
// I am checking if it is the user's first
// time to login so I can mandatory redirect
// them to the setup page.
isFirstLogin().then(firstLogin => {
if (firstLogin) {
next({ name: 'first-login' }) // this causes infinite loop
} else {
next()
}
});
} else {
next({ name: 'logout' }); // this causes infinite loop
}
})
})
然而,这一行next({ name: 'first-login' })
会导致无限循环。
如何防止这种情况?感谢。