【问题标题】:Angularfire auth confirmPasswordReset does not exist on type User用户类型上不存在 Angularfire auth confirmPasswordReset
【发布时间】:2019-08-08 00:33:58
【问题描述】:

我正在尝试使用 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 对象上的一个有效函数。

【问题讨论】:

    标签: angular firebase firebase-authentication angularfire


    【解决方案1】:

    你必须使用@angular/fire/auth

    1. 在您的构造函数中注入 AngularFireAuth
    2. 从你的 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) 
         }
       }
      

    【讨论】:

      猜你喜欢
      • 2018-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-13
      • 2018-01-20
      相关资源
      最近更新 更多