in my angular app used firebase as db, connected the app with firebase with angular/fire in module.ts and the environment of firebase is done, its working fine for login and signup, when user is signed in the firestore data is not fetching, throws error in console and when the firestore rules is changed to open its working fine , not working when rules is restricted to authenticated users.
> Error: core.js:6185 ERROR FirebaseError: Missing or insufficient
> permissions.
> at new e (prebuilt-109c6673-0f51e182.js:188)
> at prebuilt-109c6673-0f51e182.js:10416
> at prebuilt-109c6673-0f51e182.js:10417
> at e.onMessage (prebuilt-109c6673-0f51e182.js:10439)
> at prebuilt-109c6673-0f51e182.js:10356
> at prebuilt-109c6673-0f51e182.js:10387
> at prebuilt-109c6673-0f51e182.js:15194
> at ZoneDelegate.invoke (zone-evergreen.js:364)
> at Zone.run (zone-evergreen.js:123)
> at zone-evergreen.js:857
this is my firestore rules:
rules_version = '1';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
Angular code:
import {AngularFireAuth} from '@angular/fire/auth'
constructor(private Auth:AngularFireAuth) {}
login(AuthData:AuthData) {
this.Auth.signInWithEmailAndPassword(AuthData.email,AuthData.password)
.then().catch(error => {
this.uiSer.snackBar(error.message,null,3000);
})
}
data fetch code: the call to fetchsendExercise() is done on required component and all other required are imported , they're working fine.
import { AngularFirestore } from "@angular/fire/firestore";
constructor(private db:AngularFirestore){}
fetchsendExercise(){
this.db.collection('exercises').snapshotChanges().pipe(map(docArray=>{
return docArray.map(doc=>{return{
id:doc.payload.doc.id,
name:doc.payload.doc.data().name,
duration:doc.payload.doc.data().duration,
calories:doc.payload.doc.data().calories
}
})
}))
.subscribe((data:Exercise[])=>{this.availableExercise=data
this.fetchExercise.next([...this.availableExercise])
this.ui.exerciseLoading.next(false);
})
}
i found the solution to my problem, it's error from the latest firebase, after rolledback to previous version its working fine, run npm i firebase@8.6.1