|
|
@ -2,12 +2,16 @@ import { TokenStorageService } from '@ghostfolio/client/services/token-storage.s |
|
|
import { WebAuthnService } from '@ghostfolio/client/services/web-authn.service'; |
|
|
import { WebAuthnService } from '@ghostfolio/client/services/web-authn.service'; |
|
|
import { GfLogoComponent } from '@ghostfolio/ui/logo'; |
|
|
import { GfLogoComponent } from '@ghostfolio/ui/logo'; |
|
|
|
|
|
|
|
|
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; |
|
|
import { |
|
|
|
|
|
ChangeDetectorRef, |
|
|
|
|
|
Component, |
|
|
|
|
|
DestroyRef, |
|
|
|
|
|
OnInit |
|
|
|
|
|
} from '@angular/core'; |
|
|
|
|
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; |
|
|
import { MatButtonModule } from '@angular/material/button'; |
|
|
import { MatButtonModule } from '@angular/material/button'; |
|
|
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; |
|
|
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; |
|
|
import { Router } from '@angular/router'; |
|
|
import { Router } from '@angular/router'; |
|
|
import { Subject } from 'rxjs'; |
|
|
|
|
|
import { takeUntil } from 'rxjs/operators'; |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
host: { class: 'page' }, |
|
|
host: { class: 'page' }, |
|
|
@ -16,13 +20,12 @@ import { takeUntil } from 'rxjs/operators'; |
|
|
styleUrls: ['./webauthn-page.scss'], |
|
|
styleUrls: ['./webauthn-page.scss'], |
|
|
templateUrl: './webauthn-page.html' |
|
|
templateUrl: './webauthn-page.html' |
|
|
}) |
|
|
}) |
|
|
export class GfWebauthnPageComponent implements OnDestroy, OnInit { |
|
|
export class GfWebauthnPageComponent implements OnInit { |
|
|
public hasError = false; |
|
|
public hasError = false; |
|
|
|
|
|
|
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
|
|
|
|
|
|
|
|
|
public constructor( |
|
|
public constructor( |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
|
|
|
private destroyRef: DestroyRef, |
|
|
private router: Router, |
|
|
private router: Router, |
|
|
private tokenStorageService: TokenStorageService, |
|
|
private tokenStorageService: TokenStorageService, |
|
|
private webAuthnService: WebAuthnService |
|
|
private webAuthnService: WebAuthnService |
|
|
@ -35,7 +38,7 @@ export class GfWebauthnPageComponent implements OnDestroy, OnInit { |
|
|
public deregisterDevice() { |
|
|
public deregisterDevice() { |
|
|
this.webAuthnService |
|
|
this.webAuthnService |
|
|
.deregister() |
|
|
.deregister() |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(() => { |
|
|
.subscribe(() => { |
|
|
this.router.navigate(['/']); |
|
|
this.router.navigate(['/']); |
|
|
}); |
|
|
}); |
|
|
@ -46,7 +49,7 @@ export class GfWebauthnPageComponent implements OnDestroy, OnInit { |
|
|
|
|
|
|
|
|
this.webAuthnService |
|
|
this.webAuthnService |
|
|
.login() |
|
|
.login() |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe( |
|
|
.subscribe( |
|
|
({ authToken }) => { |
|
|
({ authToken }) => { |
|
|
this.tokenStorageService.saveToken(authToken, false); |
|
|
this.tokenStorageService.saveToken(authToken, false); |
|
|
@ -59,9 +62,4 @@ export class GfWebauthnPageComponent implements OnDestroy, OnInit { |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public ngOnDestroy() { |
|
|
|
|
|
this.unsubscribeSubject.next(); |
|
|
|
|
|
this.unsubscribeSubject.complete(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|