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 {FormControl, Validators} from '@angular/forms';
import { first } from 'rxjs/operators'; import { first } from 'rxjs/operators';
import { SnackBarService } from 'src/app/services/snackbar.service'; import { SnackBarService } from 'src/app/services/snackbar.service';
import { AuthService } from 'src/app/services/auth.service';
@Component({ @Component({
selector: 'app-baza.dialog', selector: 'app-baza.dialog',
@ -18,7 +19,9 @@ export class EditDialogComponent {
selectedRoles: FormControl = new FormControl(); selectedRoles: FormControl = new FormControl();
constructor(public dialogRef: MatDialogRef<EditDialogComponent>, 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('', [ formControl = new FormControl('', [
Validators.required Validators.required

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

@ -2,7 +2,7 @@
<mat-label> <mat-label>
{{label}} {{label}}
</mat-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-select-search [formControl]="searchCtrl"></mat-select-search>
<mat-option *ngFor="let risk of filteredInterfacesBMulti | async" [value]="risk">{{risk.name}}</mat-option> <mat-option *ngFor="let risk of filteredInterfacesBMulti | async" [value]="risk">{{risk.name}}</mat-option>
</mat-select> </mat-select>

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

@ -89,7 +89,7 @@
<!--<app-admin-data-page *ngIf="this.authService.getCurrentUserValue.user.roles.includes('admin')"></app-admin-data-page> <!--<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> <app-admin-data-page></app-admin-data-page>
</div> </div>

Loading…
Cancel
Save