Open cohki0305 opened 6 years ago
router.js
にて以下のようなものを記述するといい感じにリダイレクト設定ができる。
router.beforeEach((to, from, next) => {
const requiresAuth = to.matched.some(record => record.meta.requiresAuth)
const currentUser = firebase.auth().currentUser
if (requiresAuth) {
if (!currentUser) {
next({
path: '/signin',
query: {
redirect: to.fullPath
}
})
} else {
next()
}
} else {
next()
}
})
概要