All rules are working fine in simulator but not through app. I have been following youtube channel Fireship's video on google signin with custom data angluar here.
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read, write: if request.auth.uid == userId;
}
}
}
My authservice
@Injectable({ providedIn: 'root' })
export class AuthService {
user$: Observable<User>;
constructor(
private ngAuth: AngularFireAuth,
private firestore: AngularFirestore,
) {
this.user$ = this.ngAuth.authState.pipe(
switchMap(user => user ? this.userRef(user).valueChanges() : of(null)),
);
}
private userRef({ uid }): AngularFirestoreDocument {
return this.firestore.doc<User>(`users/${uid}`);
}
}
Using in html
<img *ngIf="auth.user$ | async as user" [src]="user.photoURL" alt="user">
