From e2d0dd56c68e2f452e26b172089b47d1953c928e Mon Sep 17 00:00:00 2001 From: FlayInAHook Date: Wed, 16 Dec 2020 14:07:56 +0100 Subject: [PATCH] another fix to preven admins form fing themselves --- .../admin-data-page/admin-data-page.component.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/components/admin-data-page/admin-data-page.component.ts b/src/app/components/admin-data-page/admin-data-page.component.ts index 99cc29b..6c8cf46 100644 --- a/src/app/components/admin-data-page/admin-data-page.component.ts +++ b/src/app/components/admin-data-page/admin-data-page.component.ts @@ -23,6 +23,8 @@ import {AddDialogComponent} from '../../components/dialogs/add/add.dialog.compon import {EditDialogComponent} from '../../components/dialogs/edit/edit.dialog.component'; import {deepCopy} from '../../helperFunctions/deepCopy'; +import { SnackBarService } from 'src/app/services/snackbar.service'; +import { AuthService } from 'src/app/services/auth.service'; @Component({ selector: 'app-admin-data-page', @@ -41,7 +43,9 @@ export class AdminDataPageComponent implements OnInit { constructor(public httpClient: HttpClient, public dialog: MatDialog, private userService: UserService, - private roleService: RoleService) {} + private roleService: RoleService, + private snackBarSerivice: SnackBarService, + private authService: AuthService) {} @ViewChild(MatPaginator, {static: true}) paginator: MatPaginator; @ViewChild(MatSort, {static: true}) sort: MatSort; @@ -102,6 +106,10 @@ export class AdminDataPageComponent implements OnInit { deleteItem(user : User) { + if (user.id === this.authService.getCurrentUserValue.user.id){ + this.snackBarSerivice.openSnackBar("Du kannst dich nciht selbst löschen","Ok Im an Idiot", true); + return; + } const dialogRef = this.dialog.open(DeleteDialogComponent, { data: user });