From d120c6257619216322c9bd97ccc8fe22ac33ee4c Mon Sep 17 00:00:00 2001 From: spsaefan <117728614+spsaefan@users.noreply.github.com> Date: Tue, 7 Jul 2026 01:01:08 +0200 Subject: [PATCH] Add frontend permission checks --- webapp/src/app/api/model/accountProfile.ts | 1 + .../app/shared/services/credential.service.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/webapp/src/app/api/model/accountProfile.ts b/webapp/src/app/api/model/accountProfile.ts index b40876f2..956d43aa 100644 --- a/webapp/src/app/api/model/accountProfile.ts +++ b/webapp/src/app/api/model/accountProfile.ts @@ -14,6 +14,7 @@ export interface AccountProfile { email: string; name: string; role: UserRole; + permissions?: Array; organization_id: string; organization_name: string; deleted: boolean; diff --git a/webapp/src/app/shared/services/credential.service.ts b/webapp/src/app/shared/services/credential.service.ts index e70311a2..7613806a 100644 --- a/webapp/src/app/shared/services/credential.service.ts +++ b/webapp/src/app/shared/services/credential.service.ts @@ -83,6 +83,22 @@ export class CredentialService { () => this.accountProfile()?.organization_name ?? '', ); + public readonly permissions = computed( + () => this.accountProfile()?.permissions ?? [], + ); + + public readonly canReadAccounts = computed(() => + this.permissions().includes('READ_ACCOUNTS'), + ); + + public readonly canManageAccounts = computed(() => + this.permissions().includes('MANAGE_ACCOUNTS'), + ); + + public readonly canManageOrganizations = computed(() => + this.permissions().includes('MANAGE_ORGANIZATIONS'), + ); + public readonly realAccountId = computed( () => this.accessToken()?.real_account_id ?? '', );