angular - Angularfire auth confirmPasswordReset 在用户类型上不存在
问题描述
我正在尝试使用 angularfire2/auth 类实现密码重置功能,遵循此处的实现:https ://medium.com/@c_innovative/implementing-password-reset-can-be-a-tricky-but-inevitable -task-737badfb7bab
我的代码与下面的基本相同:但出现错误
“'Observable(User)' 类型上不存在属性 'confirmPasswordReset'
handleResetPassword() {
if (this.newPassword != this.confirmPassword) {
this.matSnackBar.open("Passwords do not match.", null, { duration: 4000 });
return;
}
// Save the new password.
this.authService.getAuth().confirmPasswordReset(
this.actionCode,
this.newPassword
).then(resp => {
// Password reset has been confirmed and new password updated.
alert('New password has been saved');
this.router.navigate(['/login']); }).catch(e => {
// Error occurred during confirmation. The code might have
// expired or the password is too weak. alert(e);
});
}
没有实现 REST 解决方法,有谁知道为什么这个 angularFire auth 方法似乎不起作用?它应该是 auth 对象上的有效函数。
解决方案
你必须使用@angular/fire/auth
- 在构造函数中注入 AngularFireAuth
从您的 handleResetPassword 方法中使用注入的属性
import { AngularFireAuth } from '@angular/fire/auth'; @Injectable({ providedIn: 'root' }) export class UserService { constructor(private fbAuth: AngularFireAuth) {} handleResetPassword() { // call comfirmPasswordReset method like this this.fbAuth.auth.confirmPasswordReset(this.actionCode,this.newPassword) } }
推荐阅读
- java - 如何将输入数据从一个文件复制到另一个文件?在java中
- jwt - 从模数和指数生成公钥(再次)
- javascript - 在javascript中将日期转换为有线格式(YYYY-MM-DD)
- gtk - 如何在 ShortcutsWindow 中显示快捷方式?
- .net-core - UWP 和 .NetCore - 不一致的字体系列名称
- android - Firestore 安全规则仅允许访问特定查询而不是整个集合
- ruby-on-rails - 安装 pg (1.2.3) 时出错,Bundler 无法继续
- label - 不能在新的自定义程序中使用标签
- azure - Azure Function App Cosmos DB 触发连接断开
- javascript - 在onload javascript中禁用回车