From 985fe9cc8bf3e26f80ff3080bac465f24de62a04 Mon Sep 17 00:00:00 2001 From: Sean Engelhardt Date: Fri, 8 Mar 2019 11:53:25 +0100 Subject: [PATCH] Prevent drag and final versions without perms Fixes an issue where users without manage rights were able to use the drag and drop feature of the list of speakers. Also hides "modified final version" prints without sufficient permissions. Alters OSPerms to support "and" operators, so "perm" and "other condition" is now possible --- .../sorting-list/sorting-list.component.html | 4 ++-- .../sorting-list/sorting-list.component.ts | 6 ++++++ .../app/shared/directives/perms.directive.ts | 21 ++++++++++++++++++- .../list-of-speakers.component.html | 8 ++++++- .../list-of-speakers.component.ts | 4 ++++ .../motion-detail.component.html | 4 ++-- 6 files changed, 41 insertions(+), 6 deletions(-) diff --git a/client/src/app/shared/components/sorting-list/sorting-list.component.html b/client/src/app/shared/components/sorting-list/sorting-list.component.html index 84a8259b8..4a60edd7c 100644 --- a/client/src/app/shared/components/sorting-list/sorting-list.component.html +++ b/client/src/app/shared/components/sorting-list/sorting-list.component.html @@ -1,9 +1,9 @@ -
+
No data
-
+
drag_indicator
diff --git a/client/src/app/shared/components/sorting-list/sorting-list.component.ts b/client/src/app/shared/components/sorting-list/sorting-list.component.ts index ba453fa4f..42ec97ec7 100644 --- a/client/src/app/shared/components/sorting-list/sorting-list.component.ts +++ b/client/src/app/shared/components/sorting-list/sorting-list.component.ts @@ -59,6 +59,12 @@ export class SortingListComponent implements OnInit, OnDestroy { @Input() public count = false; + /** + * Can be set to false to disable drag n drop + */ + @Input() + public enable = true; + /** * The Input List Values * diff --git a/client/src/app/shared/directives/perms.directive.ts b/client/src/app/shared/directives/perms.directive.ts index 8ee3f8cef..2001fcaff 100644 --- a/client/src/app/shared/directives/perms.directive.ts +++ b/client/src/app/shared/directives/perms.directive.ts @@ -47,6 +47,12 @@ export class PermsDirective implements OnInit, OnDestroy { */ private complement: boolean; + /** + * Add a true-false-condition additional to osPerms + * `*osPerms="'motions.can_manage';and:isRecoMode(ChangeRecoMode.Final)"` + */ + private and = true; + private operatorSubscription: Subscription | null; /** @@ -110,6 +116,16 @@ export class PermsDirective implements OnInit, OnDestroy { this.updateView(); } + /** + * Comes from the view. + * `;and:` turns into osPermsAnd during runtime. + */ + @Input('osPermsAnd') + public set osPermsAnd(value: boolean) { + this.and = value; + this.updateView(); + } + /** * Shows or hides certain content in the view. */ @@ -133,7 +149,10 @@ export class PermsDirective implements OnInit, OnDestroy { * Returns true if the users permissions fit. */ private checkPermissions(): boolean { - const hasPerms = this.permissions.length === 0 || this.operator.hasPerms(...this.permissions); + const hasPerms = this.and + ? this.permissions.length === 0 || this.operator.hasPerms(...this.permissions) + : false; + if (this.complement) { return !hasPerms; } else { diff --git a/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.html b/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.html index cf3a3008f..4857ec021 100644 --- a/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.html +++ b/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.html @@ -60,7 +60,13 @@
- + diff --git a/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.ts b/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.ts index f4857d044..6097af445 100644 --- a/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.ts +++ b/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.ts @@ -176,6 +176,10 @@ export class ListOfSpeakersComponent extends BaseViewComponent implements OnInit }); } + public opCanManage(): boolean { + return this.op.hasPerms('agenda.can_manage_list_of_speakers'); + } + /** * Check the URL to determine a current list of Speakers */ diff --git a/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.html b/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.html index a1351161b..32fd6d9ce 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.html +++ b/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.html @@ -495,7 +495,7 @@ type="button" mat-icon-button matTooltip="{{ 'Create final print template' | translate }}" - *ngIf="isRecoMode(ChangeRecoMode.Final)" + *osPerms="'motions.can_manage';and:isRecoMode(ChangeRecoMode.Final)" (click)="createModifiedFinalVersion()" > description @@ -878,7 +878,7 @@