diff --git a/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.component.ts b/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.component.ts
index fa543974ab..8c2bb0353a 100644
--- a/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.component.ts
+++ b/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.component.ts
@@ -6,6 +6,7 @@ import { Filter, PortfolioPosition } from '@ghostfolio/common/interfaces';
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
import {
Scope,
+ canGrantRestrictedWriteAccess,
getAccessLevel,
getScopesOfAccess,
getScopesOfAccessLevel,
@@ -125,6 +126,10 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit {
return this.hasExperimentalFeatures && this.hasPermissionToEnableMcp;
}
+ public get canGrantRestrictedWriteAccess() {
+ return canGrantRestrictedWriteAccess({ type: this.accessType });
+ }
+
public get canGrantWriteAccess() {
return this.hasExperimentalFeatures;
}
@@ -195,25 +200,16 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit {
// Narrow the permission to the scopes which the type permits, because
// an access which is not granted to a user never exposes the monetary
- // values and a public access never changes data. The type PRIVATE has
- // no restricted write level, hence the permission to change the data
- // exposes the monetary values
- const accessLevelOfType = getAccessLevel(
- getScopesOfAccess({
- scopes: getScopesOfAccessLevel(this.accessLevel),
- type: accessType
- })
+ // values and a public access never changes data
+ this.accessForm.get('accessLevel')?.setValue(
+ getAccessLevel(
+ getScopesOfAccess({
+ scopes: getScopesOfAccessLevel(this.accessLevel),
+ type: accessType
+ })
+ )
);
- this.accessForm
- .get('accessLevel')
- ?.setValue(
- accessType === 'PRIVATE' &&
- this.accessLevel === 'CREATE_READ_RESTRICTED_UPDATE_DELETE'
- ? 'CREATE_READ_UPDATE_DELETE'
- : accessLevelOfType
- );
-
if (!canApplyFiltersToAccess({ type: accessType })) {
this.accessForm.get('filters')?.setValue(null);
}
diff --git a/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.html b/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.html
index eb8964d469..21c0cd3a8b 100644
--- a/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.html
+++ b/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.html
@@ -82,7 +82,7 @@
- @if (accessForm.get('type')?.value === 'MCP') {
+ @if (canGrantRestrictedWriteAccess) {
= {
MCP: [...SCOPES_OF_READ_RESTRICTED_ACCESS, scopes.activityCreate],
@@ -72,6 +74,14 @@ const SCOPES_OF_TYPE: Record = {
PUBLIC: SCOPES_OF_PUBLIC_ACCESS
};
+/**
+ * Access types which combine a write scope with the restricted read access,
+ * because their tools change data without exposing the monetary values
+ */
+export function canGrantRestrictedWriteAccess({ type }: { type: AccessType }) {
+ return type === 'MCP';
+}
+
/**
* Access level which the scopes of an access grant
*/
@@ -96,10 +106,8 @@ export function getScopesOfAccess({
}): string[] {
const scopesToEvaluate = scopesOfAccess ?? [];
- // The type PRIVATE has no restricted write level, hence a write scope stays
- // ineffective without the scope to read the monetary values
const permitsWriteAccess =
- type !== 'PRIVATE' ||
+ canGrantRestrictedWriteAccess({ type }) ||
hasScope(scopesToEvaluate, scopes.portfolioReadValues);
// An unknown scope is dropped