validateForgotPasswordModal() {
    console.log('validateForgotPasswordModal');

    // make sure forgotEmail has a value
    let firebaseObs = PromiseObservable.create(this.firebase.sendPasswordResetEmail(this.forgotEmail));

    firebaseObs.subscribe(
      () => {
        console.log("sendPasswordResetEmail ");
        Materialize.toast("Email envoyé", 3000, 'rounded');
        this.cancelForgotPasswordModal();
        this.cd.detectChanges();
      },
      error => {
        /**
         * {code: "auth/invalid-email", message: "The email address is badly formatted."}code: "auth/invalid-email"message: "The email address is badly formatted."__proto__: Error
         *
         * O {code: "auth/user-not-found", message: "There is no user record corresponding to this identifier. The user may have been deleted."}code: "auth/user-not-found"message: "There is no user record corresponding to this identifier. The user may have been deleted."__proto__: Error
         */

        console.log("sendPasswordResetEmail fail reason", error);

        if (error != undefined) {
          if (error.code == "auth/invalid-email") {
            Materialize.toast("L'email n'est pas correctement formatté", 3000, 'rounded');
            return
          } else if (error.code == "auth/user-not-found") {
            Materialize.toast("L'email ne correspond à aucun de nos utilisateurs", 3000, 'rounded');
            return
          }
        }
        Materialize.toast("Une erreur est survenue", 3000, 'rounded');
      }
    ).unsubscribe();
  }
Example #2
0
 static fromPromise(promise: Promise<any>): Observable<any> {
   return PromiseObservable.create(promise);
 }