renamed user collection

This commit is contained in:
2020-04-24 15:13:19 +02:00
committed by smuddy
parent 888d1e74b1
commit 0e8a493deb
2 changed files with 4 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
rules_version = '2'; rules_version = '2';
service cloud.firestore { service cloud.firestore {
match /databases/{database}/documents { match /databases/{database}/documents {
match /user/{user} { match /users/{user} {
allow read: if resource.id == request.auth.uid; allow read: if resource.id == request.auth.uid;
allow write: if resource.id == request.auth.uid; allow write: if resource.id == request.auth.uid;
} }

View File

@@ -12,7 +12,7 @@ export class UserService {
constructor(private afAuth: AngularFireAuth, private db: DbService) { constructor(private afAuth: AngularFireAuth, private db: DbService) {
this.afAuth.authState.pipe( this.afAuth.authState.pipe(
filter(_ => !!_), filter(_ => !!_),
switchMap(auth => this.db.doc$<User>('user/' + auth.uid)), switchMap(auth => this.db.doc$<User>('users/' + auth.uid)),
).subscribe(_ => this._user$.next(_)); ).subscribe(_ => this._user$.next(_));
} }
@@ -23,10 +23,10 @@ export class UserService {
} }
public getUserbyId$(userId: string): Observable<User> { public getUserbyId$(userId: string): Observable<User> {
return this.db.doc$<User>('user/' + userId); return this.db.doc$<User>('users/' + userId);
} }
public async update$(uid: string, data: Partial<User>): Promise<void> { public async update$(uid: string, data: Partial<User>): Promise<void> {
await this.db.doc<User>('user/' + uid).update(data); await this.db.doc<User>('users/' + uid).update(data);
} }
} }