我正在使用Angular 9和firebase。当用户注册时,他们会收到验证电子邮件,当他们单击该电子邮件时,他们会被带到验证屏幕,表明该电子邮件已通过验证。但是,当他们登录时说电子邮件未验证时,他们得到了一个错误。该页面必须重新加载才能正常工作。
onSignup(form: NgForm) {
this.submitted = true;
if (form.valid) {
this.authService.RegisterUser(this.signup.username, this.signup.password)
.then((res) => {
// Do something here
this.authService.SendVerificationMail();
this.router.navigateByUrl('/email-verification');
}).catch((error) => {
window.alert(error.message)
})
}
}
这是来自auth服务的发送验证邮件。
SendVerificationMail() {
this.ngFireAuth.onAuthStateChanged(function(user) {
user.sendEmailVerification();
});
}
为什么会这样,我该怎么办?