AngularFire 2 sendPasswordResetEmail

I want to implement the reset password / forgotten password function using AngularFire2. It looks like the sendPasswordResetEmail function is not yet provided by AngularFire2 or the data is not being updated. Since sendPasswordResetEmail is part of AngularFireAuth, I thought I could still access this function:

(this.af.auth as any).sendPasswordResetEmail('email'). then((result: any) => { console.log('Result:', result); }).catch((err: any) => { console.log('Err:', err); }); 

Typescript gives me this error:

 error TS2349: Cannot invoke an expression whose type lacks a call signature. 

Since I am new to typescript + angular2, any tips how can I access sendPasswordResetEmail ?. I assume that I need to access the pure js sdk provided by firebase, but I don't know how to do this.

Thanks.

+5
source share
1 answer

You may be able to use existing but not fully implemented AngularFire2 SDK functions by injecting FirebaseApp in the component constructor, as shown below. This will give you access to the sendPasswordResetEmail method:

 import { Component, Inject } from '@angular/core'; import { AngularFire, FirebaseApp } from 'angularfire2'; @Component({ selector: 'app-forgot-password', template: '...' }) export class ForgotPasswordComponent { private auth: any; constructor(private af : AngularFire, @Inject(FirebaseApp) fa : any) { this.auth = fa.auth(); } onSubmit() { this.auth.sendPasswordResetEmail(this.user.email) .then( resp => console.log('sent!') ) .catch( error => console.log('failed to send', error) ); } } 

Note that you will need to declare your FirebaseApp instance as any now.

+5
source

All Articles