Eric Muriithi
Eric Muriithi

Reputation: 37

error TS2339: Property 'auth' does not exist on type 'AngularFireAuth'

so I'm working on my ionic4 app and got an error on the auth in the try-catch block. I have tried installing the firebase package and adding the auth import but nothing seems to be working. What could be the problem?

import { Injectable } from '@angular/core';
import { AngularFireAuth } from '@angular/fire/auth';
import { Auth } from 'firebase';

@Injectable({
  providedIn: 'root'
})
export class FirebaseAuthService {
  auth: any[];

  constructor(private angularFireAuth: AngularFireAuth) { }

  async registerWithEmailPassword(email, password) {
    try {
      const result = await this.angularFireAuth.auth.createUserWithEmailAndPassword(email, password);
      await this.angularFireAuth.auth.currentUser.sendEmailVerification();
      return result;
    } catch (error) {
      throw new Error(error);
    }
  }
}

Upvotes: 1

Views: 664

Answers (1)

Joko Supriyanto
Joko Supriyanto

Reputation: 108

With the latest AngularFireAuth, you do not need to specify .auth anymore.

you can directly access angularFireAuth.currentUser to get the user information.

Upvotes: 1

Related Questions