在AngularFire2中使用sendEmailVerification方法时Firebase验证电子邮件问题

在AngularFire2中使用sendEmailVerification方法时Firebase验证电子邮件问题,angular,firebase,firebase-authentication,angular6,angularfire2,Angular,Firebase,Firebase Authentication,Angular6,Angularfire2,技术堆栈: 目前正在使用angular6、firebase、angularfire2和angularcli6 尝试/问题: 目前我正在注册Firebase sendEmailVerification 这会向用户发送一封电子邮件以验证其帐户 他们点击链接,它会将用户发送到我网站上的帐户管理页面 然后我需要将字段emailVerified更新为true,但它不允许我,因为它是一个只读字段 当emailVerified设置为true时,我如何更新currentUser,因为Firebase似乎不会自动

技术堆栈:

目前正在使用angular6、firebase、angularfire2和angularcli6

尝试/问题:

目前我正在注册Firebase sendEmailVerification

这会向用户发送一封电子邮件以验证其帐户

他们点击链接,它会将用户发送到我网站上的帐户管理页面

然后我需要将字段emailVerified更新为true,但它不允许我,因为它是一个只读字段

当emailVerified设置为true时,我如何更新currentUser,因为Firebase似乎不会自动为我更新


您可以使用
user.reload()
API来完成此操作。检查此处的文档:

当您向用户发送电子邮件验证链接时,该链接与以下内容非常相似

当用户单击链接时,它会将您重定向到域的新密码路由(localhost:4200)

您可以在firebase身份验证>模板>电子邮件地址验证模板更改发送到用户电子邮件地址的url处更改路由和组件

您需要自己使用url中提供的oobCode,使用checkActionCode和applyActionCode方法实现电子邮件验证逻辑

我已经实现了如下

从'@angular/core'导入{Component,OnInit};
从'@angular/router'导入{ActivatedRoute};
从“firebase”导入*作为firebase;
@组成部分({
选择器:“应用程序新密码”,
templateUrl:'./new password.component.html',
样式URL:['./新密码.component.css']
})
导出类NewPasswordComponent实现OnInit{
emailVerificationCode:字符串;
apiKey:字符串;
构造函数(私有activatedRoute:activatedRoute){
this.activatedRoute.queryParams.subscribe(参数=>{
this.emailVerificationCode=params['oobCode'];
});
}
恩戈尼尼特(){
firebase.auth().checkActionCode(this.emailVerificationCode)。然后(
(用户)=>{
log(“用户信息kkkk:+User.data.email”);
firebase.auth().applyActionCode(此.emailVerificationCode)。然后(
()=>{
设ref=firebase.database().ref('verifiedEmails/'+user.data.email.replace('.','*');
参考设置(真)。然后(
()=>{
控制台日志(“电子邮件验证”);
}
).接住(
(错误)=>{
console.log(“无法设置为真:+错误消息”);
}
)
}
).接住(
(错误)=>{
console.log(“发生错误:+Error.message”);
}
)
}
)
}

}
谢谢,我会尽快尝试。我尝试过,emailVerified字段仍然为false。我怎样才能做到这一点?因为单击电子邮件中的验证链接不起作用?谢谢,我会试试这个shortly@Prakash卡德卡:一个问题。使用原因:let ref=firebase.database().ref('verifiedEmails/'+user.data.email.replace('.','*');