implemented a fix to prevent admins from fing themselves

master
FlayInAHook 4 years ago
parent d143bab32d
commit 354da349ad

@ -4,6 +4,7 @@ import {UserService} from '../../../services/user.service';
import {FormControl, Validators} from '@angular/forms';
import { first } from 'rxjs/operators';
import { SnackBarService } from 'src/app/services/snackbar.service';
import { AuthService } from 'src/app/services/auth.service';
@Component({
selector: 'app-baza.dialog',
@ -18,7 +19,9 @@ export class EditDialogComponent {
selectedRoles: FormControl = new FormControl();
constructor(public dialogRef: MatDialogRef<EditDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any, public userService: UserService, public snackbarService : SnackBarService) { }
@Inject(MAT_DIALOG_DATA) public data: any, public userService: UserService,
public snackbarService : SnackBarService,
public authService : AuthService) { }
formControl = new FormControl('', [
Validators.required

@ -36,6 +36,7 @@
<select-search class="mat-form-field" label="Rollen"
[formCtrl]="selectedRoles"
[data]="data.rolesData"
[disabled]="authService.getCurrentUserValue.user.id === data.id"
[preSelectedData]="data.roles" multiple></select-search>
</div>

@ -2,7 +2,7 @@
<mat-label>
{{label}}
</mat-label>
<mat-select [ngModel]="selectedOptions" (ngModelChange)="selectedOptions" [formControl]="formCtrl" [multiple]="multiple">
<mat-select [ngModel]="selectedOptions" (ngModelChange)="selectedOptions" [formControl]="formCtrl" [multiple]="multiple" [disabled]="disabled">
<mat-select-search [formControl]="searchCtrl"></mat-select-search>
<mat-option *ngFor="let risk of filteredInterfacesBMulti | async" [value]="risk">{{risk.name}}</mat-option>
</mat-select>

@ -17,6 +17,7 @@ export class FormSelectSearchComponent implements OnInit, OnDestroy, OnChanges {
@Input() preSelectedData: any[];
@Input() label: string;
@Input() multiple: boolean;
@Input() disabled: boolean;
selectedOptions: any[] = [];

@ -89,7 +89,7 @@
<!--<app-admin-data-page *ngIf="this.authService.getCurrentUserValue.user.roles.includes('admin')"></app-admin-data-page>
-->
<div id="usermanagement" *ngIf="!authService.getCurrentUserValue.user.rolesString.includes('SUPERADMIN')">
<div id="usermanagement" *ngIf="authService.getCurrentUserValue.user.rolesString.includes('SUPERADMIN')">
<app-admin-data-page></app-admin-data-page>
</div>

Loading…
Cancel
Save