router.beforeEach((to, from, next) => {
const auth = getAuth()
auth.onAuthStateChanged(user => {
if (!user && to.path !== '/auth') {
next('/auth')
}
else if (user && to.path === '/auth') {
next(from.path)
}
next()
})
})