diff --git a/apps/client/src/app/pages/register/register-page.component.ts b/apps/client/src/app/pages/register/register-page.component.ts index 86490688b..34d72980a 100644 --- a/apps/client/src/app/pages/register/register-page.component.ts +++ b/apps/client/src/app/pages/register/register-page.component.ts @@ -7,7 +7,6 @@ import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { Component, OnDestroy, OnInit } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { Router } from '@angular/router'; -import { Role } from '@prisma/client'; import { DeviceDetectorService } from 'ngx-device-detector'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; @@ -59,15 +58,6 @@ export class RegisterPageComponent implements OnDestroy, OnInit { ); } - public async createAccount() { - this.dataService - .postUser() - .pipe(takeUntil(this.unsubscribeSubject)) - .subscribe(({ accessToken, authToken, role }) => { - this.openShowAccessTokenDialog(accessToken, authToken, role); - }); - } - public async onLoginWithInternetIdentity() { try { const { authToken } = await this.internetIdentityService.login(); @@ -76,16 +66,12 @@ export class RegisterPageComponent implements OnDestroy, OnInit { } catch {} } - public openShowAccessTokenDialog( - accessToken: string, - authToken: string, - role: Role - ) { + public openShowAccessTokenDialog() { const dialogRef = this.dialog.open(ShowAccessTokenDialog, { data: { - accessToken, - authToken, - role + accessToken: undefined, + authToken: undefined, + role: undefined }, disableClose: true, width: '30rem' @@ -96,7 +82,7 @@ export class RegisterPageComponent implements OnDestroy, OnInit { .pipe(takeUntil(this.unsubscribeSubject)) .subscribe((data) => { if (data?.authToken) { - this.tokenStorageService.saveToken(authToken, true); + this.tokenStorageService.saveToken(data.authToken, true); this.router.navigate(['/']); } diff --git a/apps/client/src/app/pages/register/register-page.html b/apps/client/src/app/pages/register/register-page.html index 903aedccf..eee49083a 100644 --- a/apps/client/src/app/pages/register/register-page.html +++ b/apps/client/src/app/pages/register/register-page.html @@ -22,7 +22,7 @@ class="d-inline-block" color="primary" mat-flat-button - (click)="createAccount()" + (click)="openShowAccessTokenDialog()" > Create Account diff --git a/apps/client/src/app/pages/register/show-access-token-dialog/show-access-token-dialog.component.ts b/apps/client/src/app/pages/register/show-access-token-dialog/show-access-token-dialog.component.ts index ebe9983c0..9535072b1 100644 --- a/apps/client/src/app/pages/register/show-access-token-dialog/show-access-token-dialog.component.ts +++ b/apps/client/src/app/pages/register/show-access-token-dialog/show-access-token-dialog.component.ts @@ -1,5 +1,15 @@ -import { ChangeDetectionStrategy, Component, Inject } from '@angular/core'; +import { DataService } from '@ghostfolio/client/services/data.service'; + +import { + ChangeDetectionStrategy, + Component, + Inject, + ViewChild +} from '@angular/core'; import { MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { MatStepper } from '@angular/material/stepper'; +import { Subject } from 'rxjs'; +import { takeUntil } from 'rxjs/operators'; @Component({ selector: 'gf-show-access-token-dialog', @@ -9,10 +19,16 @@ import { MAT_DIALOG_DATA } from '@angular/material/dialog'; standalone: false }) export class ShowAccessTokenDialog { + @ViewChild(MatStepper) stepper!: MatStepper; public isCreateAccountButtonDisabled = true; public disclaimerChecked = false; - public constructor(@Inject(MAT_DIALOG_DATA) public data: any) {} + private unsubscribeSubject = new Subject(); + + public constructor( + @Inject(MAT_DIALOG_DATA) public data: any, + private dataService: DataService + ) {} public onChangeDislaimerChecked() { this.disclaimerChecked = !this.disclaimerChecked; @@ -21,4 +37,18 @@ export class ShowAccessTokenDialog { public enableCreateAccountButton() { this.isCreateAccountButtonDisabled = false; } + + public async createAccount() { + this.dataService + .postUser() + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe(({ accessToken, authToken, role }) => { + this.data = { + accessToken, + authToken, + role + }; + this.stepper.next(); + }); + } } diff --git a/apps/client/src/app/pages/register/show-access-token-dialog/show-access-token-dialog.html b/apps/client/src/app/pages/register/show-access-token-dialog/show-access-token-dialog.html index 7b5cbfc0d..e239c72d3 100644 --- a/apps/client/src/app/pages/register/show-access-token-dialog/show-access-token-dialog.html +++ b/apps/client/src/app/pages/register/show-access-token-dialog/show-access-token-dialog.html @@ -41,8 +41,8 @@ color="primary" i18n mat-flat-button - matStepperNext [disabled]="!disclaimerChecked" + (click)="createAccount()" > Continue