Browse Source

Improve user account deletion flow

pull/7269/head
Thomas Kaul 1 week ago
parent
commit
70ebf23d9e
  1. 21
      apps/client/src/app/components/user-account-settings/user-account-settings.component.ts
  2. 12
      apps/client/src/app/components/user-account-settings/user-account-settings.html

21
apps/client/src/app/components/user-account-settings/user-account-settings.component.ts

@ -1,3 +1,4 @@
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service';
import {
KEY_STAY_SIGNED_IN,
KEY_TOKEN,
@ -76,6 +77,8 @@ export class GfUserAccountSettingsComponent implements OnInit {
public deleteOwnUserForm = this.formBuilder.group({
accessToken: ['', Validators.required]
});
public hasImpersonationId: boolean;
public hasPermissionForSubscription: boolean;
public hasPermissionToDeleteOwnUser: boolean;
public hasPermissionToUpdateViewMode: boolean;
public hasPermissionToUpdateUserSettings: boolean;
@ -108,17 +111,33 @@ export class GfUserAccountSettingsComponent implements OnInit {
private dataService: DataService,
private destroyRef: DestroyRef,
private formBuilder: FormBuilder,
private impersonationStorageService: ImpersonationStorageService,
private notificationService: NotificationService,
private settingsStorageService: SettingsStorageService,
private snackBar: MatSnackBar,
private userService: UserService,
public webAuthnService: WebAuthnService
) {
const { baseCurrency, currencies } = this.dataService.fetchInfo();
const { baseCurrency, currencies, globalPermissions } =
this.dataService.fetchInfo();
this.baseCurrency = baseCurrency;
this.currencies = currencies;
this.hasPermissionForSubscription = hasPermission(
globalPermissions,
permissions.enableSubscription
);
this.impersonationStorageService
.onChangeHasImpersonation()
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((impersonationId) => {
this.hasImpersonationId = !!impersonationId;
this.changeDetectorRef.markForCheck();
});
this.userService.stateChanged
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((state) => {

12
apps/client/src/app/components/user-account-settings/user-account-settings.html

@ -285,6 +285,10 @@
</button>
</div>
</div>
@if (
!hasImpersonationId &&
(hasPermissionToDeleteOwnUser || hasPermissionForSubscription)
) {
<hr class="mt-5" />
<div class="d-flex py-1">
<div class="pr-1 text-danger w-50" i18n>Danger Zone</div>
@ -334,18 +338,22 @@
Close Account
</button>
</form>
} @else if (user?.accounts?.length > 0 || user?.activitiesCount > 0) {
} @else if (
hasPermissionForSubscription &&
(user?.accounts?.length > 0 || user?.activitiesCount > 0)
) {
<div class="hint-text text-muted" i18n>
For security reasons, please delete all activities and accounts
first before your Ghostfolio account can be closed.
</div>
} @else {
} @else if (hasPermissionForSubscription) {
<a color="warn" i18n mat-flat-button [href]="closeUserAccountMail"
>Close Account</a
>
}
</div>
</div>
}
</div>
</div>
</div>

Loading…
Cancel
Save