【发布时间】:2020-09-30 22:29:51
【问题描述】:
我在 vue 应用程序中使用 firebase 身份验证 每次登录用户后重新启动页面时 currentUser 变为 null
firebase.auth().signInWithEmailAndPassword(this.email, this.password)
.then(() => this.$router.push({name: 'Home'}))
.catch(err => this.feedback = err.message)
在 vue 路由器中
router.beforeEach((to, from, next) => {
if (to.matched.some(record => record.meta.requiresAuth)) {
let user = firebase.auth().currentUser
if (!user) {
next({name: 'Login'})
} else next()
} else next()
})
我希望用户不是每次重新启动页面时都登录一次
【问题讨论】:
标签: firebase vue.js authentication firebase-authentication