Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property 'auth' does not exist on type 'AngularFireAuth'

Tags:

Getting this error when using angularfire. Have checked my imports and they seem to be correct. I have tried to reinstall angularfire however it is still throwing this error. Is there issues with angularfire?

import { Injectable, NgZone } from '@angular/core'; import { User } from "../services/user"; import { auth } from 'firebase/app'; import { AngularFireAuth } from "@angular/fire/auth"; import { AngularFirestore, AngularFirestoreDocument } from '@angular/fire/firestore'; import { Router } from "@angular/router";   @Injectable({   providedIn: 'root' })  export class AuthService {   userData: any; // Save logged in user data    constructor(     public afs: AngularFirestore,   // Inject Firestore service     public afAuth: AngularFireAuth, // Inject Firebase auth service     public router: Router,       public ngZone: NgZone // NgZone service to remove outside scope warning   ) {         /* Saving user data in localstorage when      logged in and setting up null when logged out */     this.afAuth.authState.subscribe(user => {       if (user) {         this.userData = user;         localStorage.setItem('user', JSON.stringify(this.userData));         JSON.parse(localStorage.getItem('user'));       } else {         localStorage.setItem('user', null);         JSON.parse(localStorage.getItem('user'));       }     })   }    // Sign in with email/password   SignIn(email, password) {     return this.afAuth.auth.signInWithEmailAndPassword(email, password)       .then((result) => {         this.ngZone.run(() => {           this.router.navigate(['dashboard']);         });         this.SetUserData(result.user);       }).catch((error) => {         window.alert(error.message)       })   } 
like image 953
Karl Mcgeough Avatar asked Feb 28 '20 16:02

Karl Mcgeough


2 Answers

Had the same problem. Seems starting "@angular/fire": "^6.0.0" AngularFireAuth has dropped the auth property.

Just delete auth & it should work

https://github.com/angular/angularfire/issues/2409#issuecomment-615993136

like image 165
Anish K Pillai Avatar answered Oct 13 '22 04:10

Anish K Pillai


Just delete the "auth", and it will work

Property 'auth' does not exist on type 'AngularFireAuth' #2409

like image 40
Muhammed Moussa Avatar answered Oct 13 '22 04:10

Muhammed Moussa