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 { import {
KEY_STAY_SIGNED_IN, KEY_STAY_SIGNED_IN,
KEY_TOKEN, KEY_TOKEN,
@ -76,6 +77,8 @@ export class GfUserAccountSettingsComponent implements OnInit {
public deleteOwnUserForm = this.formBuilder.group({ public deleteOwnUserForm = this.formBuilder.group({
accessToken: ['', Validators.required] accessToken: ['', Validators.required]
}); });
public hasImpersonationId: boolean;
public hasPermissionForSubscription: boolean;
public hasPermissionToDeleteOwnUser: boolean; public hasPermissionToDeleteOwnUser: boolean;
public hasPermissionToUpdateViewMode: boolean; public hasPermissionToUpdateViewMode: boolean;
public hasPermissionToUpdateUserSettings: boolean; public hasPermissionToUpdateUserSettings: boolean;
@ -108,17 +111,33 @@ export class GfUserAccountSettingsComponent implements OnInit {
private dataService: DataService, private dataService: DataService,
private destroyRef: DestroyRef, private destroyRef: DestroyRef,
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private impersonationStorageService: ImpersonationStorageService,
private notificationService: NotificationService, private notificationService: NotificationService,
private settingsStorageService: SettingsStorageService, private settingsStorageService: SettingsStorageService,
private snackBar: MatSnackBar, private snackBar: MatSnackBar,
private userService: UserService, private userService: UserService,
public webAuthnService: WebAuthnService public webAuthnService: WebAuthnService
) { ) {
const { baseCurrency, currencies } = this.dataService.fetchInfo(); const { baseCurrency, currencies, globalPermissions } =
this.dataService.fetchInfo();
this.baseCurrency = baseCurrency; this.baseCurrency = baseCurrency;
this.currencies = currencies; 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 this.userService.stateChanged
.pipe(takeUntilDestroyed(this.destroyRef)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((state) => { .subscribe((state) => {

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

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

Loading…
Cancel
Save