Hey Brian, great article but two things could be improved.
You should be sending an email verification during register.
data.user.sendEmailVerification();
You should use onAuthStateChanged you retrieve the current user in your BeforeEach like that:
router.beforeEach((to, from, next) => { firebase.auth().onAuthStateChanged(function(user) { let requiresAuth = to.matched.some(record => record.meta.requiresAuth); if (requiresAuth && !user) next("login"); else next(); }); });
Best,
Maxime
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey Brian, great article but two things could be improved.
You should be sending an email verification during register.
data.user.sendEmailVerification();
You should use onAuthStateChanged you retrieve the current user in your BeforeEach like that:
router.beforeEach((to, from, next) => {
firebase.auth().onAuthStateChanged(function(user) {
let requiresAuth = to.matched.some(record => record.meta.requiresAuth);
if (requiresAuth && !user) next("login");
else next();
});
});
Best,
Maxime