From 45ab4016e521f7e9978a3c92eb93b9f24d1a4a74 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Tue, 7 Jul 2026 22:28:43 +0200 Subject: [PATCH] Task/improve user account deletion flow (#7269) * Improve user account deletion flow * Update changelog --- CHANGELOG.md | 1 + apps/api/src/app/user/user.service.ts | 8 ++ .../user-account-settings.component.ts | 9 ++ .../user-account-settings.html | 110 +++++++++++------- libs/common/src/lib/permissions.ts | 1 + 5 files changed, 84 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d127948f..c111ac3c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Improved the user account deletion flow in the user settings of the user account page - Set the change detection strategy to `OnPush` in the _FIRE_ page - Set the change detection strategy to `OnPush` in the users section of the admin control panel - Improved the language localization for Dutch (`nl`) diff --git a/apps/api/src/app/user/user.service.ts b/apps/api/src/app/user/user.service.ts index 0c159bc1c..4dcf16034 100644 --- a/apps/api/src/app/user/user.service.ts +++ b/apps/api/src/app/user/user.service.ts @@ -535,6 +535,14 @@ export class UserService { user.subscription.offer.label = undefined; } + if ( + !hasRole(user, Role.DEMO) && + (user.provider !== 'ANONYMOUS' || + user.subscription?.type === SubscriptionType.Premium) + ) { + currentPermissions.push(permissions.requestOwnUserDeletion); + } + if (hasRole(user, Role.ADMIN)) { currentPermissions.push(permissions.syncDemoUserAccount); } diff --git a/apps/client/src/app/components/user-account-settings/user-account-settings.component.ts b/apps/client/src/app/components/user-account-settings/user-account-settings.component.ts index 948c5a25e..c8210b0c3 100644 --- a/apps/client/src/app/components/user-account-settings/user-account-settings.component.ts +++ b/apps/client/src/app/components/user-account-settings/user-account-settings.component.ts @@ -71,11 +71,13 @@ import { catchError } from 'rxjs/operators'; export class GfUserAccountSettingsComponent implements OnInit { public appearancePlaceholder = $localize`Auto`; public baseCurrency: string; + public closeUserAccountMail: string; public currencies: string[] = []; public deleteOwnUserForm = this.formBuilder.group({ accessToken: ['', Validators.required] }); public hasPermissionToDeleteOwnUser: boolean; + public hasPermissionToRequestOwnUserDeletion: boolean; public hasPermissionToUpdateViewMode: boolean; public hasPermissionToUpdateUserSettings: boolean; public isAccessTokenHidden = true; @@ -124,11 +126,18 @@ export class GfUserAccountSettingsComponent implements OnInit { if (state?.user) { this.user = state.user; + this.closeUserAccountMail = `mailto:hi@ghostfol.io?subject=Delete Account&body=Hello%0D%0DPlease delete my Ghostfolio account.%0D%0DUser ID: ${this.user.id}%0D%0DKind regards`; + this.hasPermissionToDeleteOwnUser = hasPermission( this.user.permissions, permissions.deleteOwnUser ); + this.hasPermissionToRequestOwnUserDeletion = hasPermission( + this.user.permissions, + permissions.requestOwnUserDeletion + ); + this.hasPermissionToUpdateUserSettings = hasPermission( this.user.permissions, permissions.updateUserSettings diff --git a/apps/client/src/app/components/user-account-settings/user-account-settings.html b/apps/client/src/app/components/user-account-settings/user-account-settings.html index cefa3a0a1..351e718ec 100644 --- a/apps/client/src/app/components/user-account-settings/user-account-settings.html +++ b/apps/client/src/app/components/user-account-settings/user-account-settings.html @@ -280,61 +280,81 @@