user detail page display permission update

This commit is contained in:
Maximilian Krambach 2019-02-18 15:02:09 +01:00 committed by Emanuel Schütze
parent 6c65fa0665
commit 567a53db03
2 changed files with 11 additions and 4 deletions

View File

@ -2,6 +2,7 @@
[mainButton]="isAllowed('changePersonal')"
mainButtonIcon="edit"
[nav]="false"
[goBack]="!isAllowed('seeOtherUsers')"
[editMode]="editUser"
(mainEvent)="setEditMode(!editUser)"
(saveEvent)="saveUser()"
@ -21,7 +22,7 @@
</div>
<mat-menu #userExtraMenu="matMenu">
<button mat-menu-item *ngIf="isAllowed('changePersonal')" (click)="changePassword()">
<button mat-menu-item *ngIf="isAllowed('changePassword')" (click)="changePassword()">
<mat-icon>security</mat-icon>
<span translate>Change password</span>
</button>
@ -40,7 +41,7 @@
</mat-menu>
</os-head-bar>
<mat-card [ngClass]="editUser ? 'os-form-card' : 'os-card'" *osPerms="'users.can_see_name'">
<mat-card [ngClass]="editUser ? 'os-form-card' : 'os-card'" *ngIf="isAllowed('seeName')">
<form
[ngClass]="{ 'mat-form-field-enabled': editUser }"
[formGroup]="personalInfoForm"
@ -156,7 +157,7 @@
matInput
placeholder="{{ 'Initial password' | translate }}"
formControlName="default_password"
[value]="user.default_password"
[value]="user.default_password || ''"
/>
<mat-hint align="end">Generate</mat-hint>
<button
@ -200,7 +201,7 @@
matInput
placeholder="{{ 'Comment' | translate }}"
formControlName="comment"
[value]="user.comment"
[value]="user.comment || ''"
/>
<mat-hint translate>Only for internal notes.</mat-hint>
</mat-form-field>

View File

@ -168,10 +168,12 @@ export class UserDetailComponent extends BaseViewComponent implements OnInit {
* actions might be:
* - delete (deleting the user) (users.can_manage and not ownPage)
* - seeName (title, 1st, last) (user.can_see_name or ownPage)
* - seeOtherUsers (title, 1st, last) (user.can_see_name)
* - seeExtra (checkboxes, comment) (user.can_see_extra_data)
* - seePersonal (mail, username, about) (user.can_see_extra_data or ownPage)
* - manage (everything) (user.can_manage)
* - changePersonal (mail, username, about) (user.can_manage or ownPage)
* - changePassword (user.can_change_password)
*
* @param action the action the user tries to perform
*/
@ -183,12 +185,16 @@ export class UserDetailComponent extends BaseViewComponent implements OnInit {
return this.operator.hasPerms('users.can_manage');
case 'seeName':
return this.operator.hasPerms('users.can_see_name', 'users.can_manage') || this.ownPage;
case 'seeOtherUsers':
return this.operator.hasPerms('users.can_see_name', 'users.can_manage');
case 'seeExtra':
return this.operator.hasPerms('users.can_see_extra_data', 'users.can_manage');
case 'seePersonal':
return this.operator.hasPerms('users.can_see_extra_data', 'users.can_manage') || this.ownPage;
case 'changePersonal':
return this.operator.hasPerms('users.can_manage') || this.ownPage;
case 'changePassword':
return this.ownPage && this.operator.hasPerms('users.can_change_password');
default:
return false;
}