Skip to content

Commit 6e7e6a0

Browse files
committed
fix user update
1 parent d727d9e commit 6e7e6a0

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

firestore.rules

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ service cloud.firestore {
8282

8383
// Users
8484
match /users/{userId} {
85-
allow get: if isSignedIn() && ( isSignedInWithUser(userId) || (hasRole('admin') || hasPermission('USER_MANAGEMENT')));
86-
allow list: if isSignedIn() && (hasRole('admin') || hasPermission('USER_MANAGEMENT'));
85+
allow read: if isSignedIn() && ( isSignedInWithUser(userId) || (hasRole('admin') || hasPermission('USER_MANAGEMENT')));
8786
allow write: if isSignedIn() && (hasRole('admin') || hasPermission('USER_MANAGEMENT'));
8887
}
8988

src/app/features/admin/users/users.component.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export class UsersComponent implements OnInit {
4949
.pipe(takeUntilDestroyed(this.destroyRef))
5050
.subscribe({
5151
next: users => {
52-
console.log(users);
5352
this.dataSource.data = users;
5453
this.dataSource.filterPredicate = this.userFilterPredicate;
5554
this.dataSource.sort = this.sort();
@@ -86,11 +85,9 @@ export class UsersComponent implements OnInit {
8685
.subscribe({
8786
next: () => {
8887
this.notificationService.success('User has been invited.');
89-
this.loadData();
9088
},
9189
error: () => {
9290
this.notificationService.error('User can not be invited.');
93-
this.loadData();
9491
},
9592
});
9693
}
@@ -113,11 +110,10 @@ export class UsersComponent implements OnInit {
113110
.subscribe({
114111
next: () => {
115112
this.notificationService.success('User has been updated.');
116-
this.loadData();
117113
},
118-
error: () => {
114+
error: (error) => {
119115
this.notificationService.error('User can not be updated.');
120-
this.loadData();
116+
console.error(error);
121117
},
122118
});
123119
}
@@ -138,11 +134,9 @@ export class UsersComponent implements OnInit {
138134
.subscribe({
139135
next: () => {
140136
this.notificationService.success(`User '${element.email}' has been deleted.`);
141-
this.loadData();
142137
},
143138
error: () => {
144139
this.notificationService.error(`User '${element.email}' can not be deleted.`);
145-
this.loadData();
146140
},
147141
});
148142
}

src/app/shared/services/user.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,21 @@ export class UserService {
3939
}
4040

4141
update(id: string, model: UserUpdate): Observable<void> {
42+
console.log('UserService:update', id, model);
4243
const update: UpdateData<User> = {
4344
updatedAt: serverTimestamp(),
4445
};
4546
switch (model.role) {
4647
case 'admin': {
4748
update.role = model.role;
4849
update.permissions = deleteField();
50+
update.lock = deleteField();
4951
break;
5052
}
5153
case 'custom': {
5254
update.role = model.role;
5355
update.permissions = model.permissions;
54-
update.lock = model.lock;
56+
update.lock = model.lock || false;
5557
break;
5658
}
5759
case undefined: {

0 commit comments

Comments
 (0)