From f9cae1a858ef2cd0c93fd2ee03381c92fe9f1df7 Mon Sep 17 00:00:00 2001 From: Aram Al-Sabti Date: Wed, 25 May 2022 14:00:35 +0200 Subject: [PATCH 1/3] Limit app admin to own apps --- src/app/admin/permission/permission.model.ts | 1 + .../application-detail.component.ts | 4 +-- .../applications-table.component.html | 2 +- .../applications-table.component.ts | 3 -- .../bulk-import/bulk-import.component.html | 2 +- .../bulk-import/bulk-import.component.ts | 4 --- .../datatarget-table.component.ts | 2 +- .../fiware-detail/fiware-detail.component.ts | 3 +- .../httppush-detail.component.ts | 3 +- .../httppush-edit/httppush-edit.component.ts | 2 +- .../mqtt-detail/mqtt-detail.component.html | 3 +- .../mqtt-detail/mqtt-detail.component.ts | 8 ++++- .../iot-device-detail.component.ts | 3 +- .../iot-device-edit.component.ts | 2 +- .../iot-devices-table.component.ts | 7 ++-- .../multicast-table.component.ts | 4 ++- .../device-model-detail.component.ts | 4 ++- .../device-model-list.component.html | 2 +- .../payload-decoder-detail.component.html | 2 +- .../payload-decoder-detail.component.ts | 2 +- .../permission/can-edit-application.pipe.ts | 18 +++++++++++ .../{ => permission}/is-global-admin.pipe.ts | 0 .../translate-permissions.pipe.ts | 0 src/app/shared/pipes/pipes.module.ts | 11 ++++--- src/app/shared/services/me.service.ts | 32 +++++++++++++------ 25 files changed, 84 insertions(+), 40 deletions(-) create mode 100644 src/app/shared/pipes/permission/can-edit-application.pipe.ts rename src/app/shared/pipes/{ => permission}/is-global-admin.pipe.ts (100%) rename src/app/shared/pipes/{ => permission}/translate-permissions.pipe.ts (100%) diff --git a/src/app/admin/permission/permission.model.ts b/src/app/admin/permission/permission.model.ts index ea0bb414a..f8777dfe5 100644 --- a/src/app/admin/permission/permission.model.ts +++ b/src/app/admin/permission/permission.model.ts @@ -23,6 +23,7 @@ export interface PermissionResponse { users?: UserResponse[]; organization?: OrganisationResponse; applications?: Application[]; + applicationIds?: number[]; id: number; createdAt: Date; updatedAt: Date; diff --git a/src/app/applications/application-detail/application-detail.component.ts b/src/app/applications/application-detail/application-detail.component.ts index 84587a0e6..707d8bdc4 100644 --- a/src/app/applications/application-detail/application-detail.component.ts +++ b/src/app/applications/application-detail/application-detail.component.ts @@ -53,7 +53,7 @@ export class ApplicationDetailComponent implements OnInit, OnDestroy { label: '', editRouterLink: '../../edit-application/' + this.id, isErasable: true, - }; + }; } this.translate @@ -68,7 +68,7 @@ export class ApplicationDetailComponent implements OnInit, OnDestroy { translations['APPLICATION-TABLE-ROW.SHOW-OPTIONS']; this.titleService.setTitle(translations['TITLE.APPLICATION']); }); - this.canEdit = this.meService.hasAccessToTargetOrganization(OrganizationAccessScope.ApplicationWrite); + this.canEdit = this.meService.hasAccessToTargetOrganization(OrganizationAccessScope.ApplicationWrite, undefined, this.id); } onDeleteApplication() { diff --git a/src/app/applications/applications-list/applications-table/applications-table.component.html b/src/app/applications/applications-list/applications-table/applications-table.component.html index c945d5a1e..3e8237f8d 100644 --- a/src/app/applications/applications-list/applications-table/applications-table.component.html +++ b/src/app/applications/applications-list/applications-table/applications-table.component.html @@ -34,7 +34,7 @@ -