I need help with my Ionic 2 app. I'm using angularfire2 to connect with firebase: https://github.com/angular/angularfire2
My app is working, saving users, and managing authentication. Now I need to know how to implement the "Forgot password" functionality.
I can't see any method for doing that with this library, but in the firebase official docs yes. But I don't know if I can include it in an Ionic 2 project.
Someone can help me?
Thank's so much in advance!
Ivan.
You need to use the firebase.auth library for this.
Use this you can use firebase().auth().sendPasswordResetEmail(email).then(res => {}); to access this functionality.
You can use it wherever you want, beeing it inside the .ts file of the page where the user'll call for a 'forgot password' method or a provider.
So do this:
import * as firebase from 'firebase';
export class MyCurrentPage {
constructor(){}
forgotPass(){
// SOMETHING TO INTERACT WITH THE USER, THEN...
firebase().auth().sendPasswordResetEmail(email).then(res => {});
}
}
I don't know if AngularFire is still installing firebase with it, if not you need to install it.
Hope it helps
If you are using AngularFire2 and you want to put it in a service. This should do. It will return an observable.
import { Injectable, Inject } from "@angular/core";
import { FirebaseApp } from "angularfire2";
import { Observable } from "rxjs";
@Injectable()
export class UserService {
firebase: any;
constructor(@Inject(FirebaseApp) fb: any) {
this.firebase = fb;
}
forgotPassword(email: string) {
return Observable.fromPromise(this.firebase.auth().sendPasswordResetEmail(email));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With