I'm facing an issue with implementing error detection in Angular Firebase. Whenever new users log in to my website, they encounter a permission error in the database, which is displayed in the console.
My goal is to have auth.isApproved return false when this error occurs, but it currently does not do so. I attempted to add a .catch to the .switchMap function, but it was unsuccessful.
The error message in the console is as follows:
Uncaught Error: permission_denied at /authorization/users/VAST9WnazFUc6u9PQ5x74bOPIsJ2: Client doesn't have permission to access the desired data.
Component where the error is encountered:
this.auth.isApproved().subscribe(approved => {
console.log(approved);
AuthService (auth):
isApproved(): Observable<boolean> {
return this.user$
.switchMap(user => this.DataService.getSharesDBUser(user.uid).valueChanges())
.map(appUser => appUser.isApproved)
}
DataService (DataService)
getSharesDBUser(userUID: string): AngularFireObject<firebaseDBUser> {
return this.db.object('/authorization/users/' + userUID);
}
Data Model Interface:
export interface firebaseDBUser {
isAdmin: boolean;
isApproved: boolean;
name: string;
}