Browse Source

Various improvements

pull/161/head
Thomas 4 years ago
parent
commit
56ff34f4f5
  1. 4
      apps/api/src/app/auth/web-auth.service.ts
  2. 10
      apps/client/src/app/app-routing.module.ts
  3. 5
      apps/client/src/app/components/header/header.component.html
  4. 12
      apps/client/src/app/pages/webauthn/webauthn-page.component.ts
  5. 21
      apps/client/src/app/pages/webauthn/webauthn-page.html
  6. 10
      apps/client/src/app/pages/webauthn/webauthn-page.module.ts

4
apps/api/src/app/auth/web-auth.service.ts

@ -58,8 +58,8 @@ export class WebAuthService {
attestationType: 'indirect',
authenticatorSelection: {
authenticatorAttachment: 'platform',
userVerification: 'required',
requireResidentKey: false
requireResidentKey: false,
userVerification: 'required'
}
};

10
apps/client/src/app/app-routing.module.ts

@ -92,11 +92,6 @@ const routes: Routes = [
(m) => m.TransactionsPageModule
)
},
{
path: 'zen',
loadChildren: () =>
import('./pages/zen/zen-page.module').then((m) => m.ZenPageModule)
},
{
path: 'webauthn',
loadChildren: () =>
@ -104,6 +99,11 @@ const routes: Routes = [
(m) => m.WebauthnPageModule
)
},
{
path: 'zen',
loadChildren: () =>
import('./pages/zen/zen-page.module').then((m) => m.ZenPageModule)
},
{
// wildcard, if requested url doesn't match any paths for routes defined
// earlier

5
apps/client/src/app/components/header/header.component.html

@ -1,9 +1,4 @@
<mat-toolbar class="p-0">
<ng-container *ngIf="!user">
<a [routerLink]="['/']" class="no-min-width px-2" mat-button>
<gf-logo></gf-logo>
</a>
</ng-container>
<ng-container *ngIf="user">
<a [routerLink]="['/']" class="no-min-width px-2" mat-button>
<gf-logo></gf-logo>

12
apps/client/src/app/pages/webauthn/webauthn-page.component.ts

@ -1,7 +1,7 @@
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service';
import { WebAuthnService } from '@ghostfolio/client/services/web-authn.service';
import { Router } from '@angular/router';
@Component({
selector: 'gf-webauthn-page',
@ -18,14 +18,14 @@ export class WebauthnPageComponent implements OnInit {
private webAuthnService: WebAuthnService
) {}
ngOnInit(): void {
public ngOnInit() {
this.signIn();
}
public deregisterDevice() {
this.webAuthnService
.deregister()
.subscribe(() => this.router.navigate(['']));
this.webAuthnService.deregister().subscribe(() => {
this.router.navigate(['/']);
});
}
public signIn() {
@ -34,7 +34,7 @@ export class WebauthnPageComponent implements OnInit {
this.webAuthnService.login().subscribe(
({ authToken }) => {
this.tokenStorageService.saveToken(authToken, false);
this.router.navigate(['']);
this.router.navigate(['/']);
},
(error) => {
console.error(error);

21
apps/client/src/app/pages/webauthn/webauthn-page.html

@ -1,23 +1,26 @@
<div class="container">
<div class="row mt-5">
<div class="row">
<div *ngIf="!hasError" class="col d-flex justify-content-center">
<mat-spinner [diameter]="100"></mat-spinner>
<mat-spinner [diameter]="20"></mat-spinner>
</div>
<div *ngIf="hasError" class="col d-flex flex-column justify-content-center">
<h3 class="d-flex justify-content-center mb-3" i18n>
Authentication failed
<div
*ngIf="hasError"
class="align-items-center col d-flex flex-column justify-content-center"
>
<h3 class="d-flex justify-content-center" i18n>
Oops, authentication failed
</h3>
<button
(click)="signIn()"
class="mb-3"
mat-flat-button
class="my-4"
color="primary"
i18n
mat-flat-button
>
Try again
</button>
<button (click)="deregisterDevice()" mat-flat-button i18n>
Forget fingerprint sign in
<button (click)="deregisterDevice()" i18n mat-flat-button>
Go back to Home Page
</button>
</div>
</div>

10
apps/client/src/app/pages/webauthn/webauthn-page.module.ts

@ -1,19 +1,19 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { WebauthnPageComponent } from '@ghostfolio/client/pages/webauthn/webauthn-page.component';
import { WebauthnPageRoutingModule } from './webauthn-page-routing.module';
import { WebauthnPageComponent } from '@ghostfolio/client/pages/webauthn/webauthn-page.component';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatButtonModule } from '@angular/material/button';
@NgModule({
declarations: [WebauthnPageComponent],
exports: [],
imports: [
WebauthnPageRoutingModule,
CommonModule,
MatButtonModule,
MatProgressSpinnerModule
MatProgressSpinnerModule,
WebauthnPageRoutingModule
],
providers: []
})

Loading…
Cancel
Save