类型为User时,Angularfire auth confirmPasswordReset不存在

问题描述 投票:0回答:1

我正在尝试使用angularfire2 / auth类实现密码重置功能,遵循以下实现:https://medium.com/@c_innovative/implementing-password-reset-can-be-a-tricky-but-inevitable-task-737badfb7bab

我的代码基本相同如下:但是我收到了一个错误

“属性'confirmPasswordReset'在类型'Observable(User)'上不存在

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 firebase firebase-authentication angularfire
1个回答
0
投票

你必须使用@ angular / fire / auth

  1. 在构造函数中注入AngularFireAuth
  2. 从handleResetPassword方法中使用inject属性 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) } }
© www.soinside.com 2019 - 2024. All rights reserved.