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', attestationType: 'indirect',
authenticatorSelection: { authenticatorSelection: {
authenticatorAttachment: 'platform', 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 (m) => m.TransactionsPageModule
) )
}, },
{
path: 'zen',
loadChildren: () =>
import('./pages/zen/zen-page.module').then((m) => m.ZenPageModule)
},
{ {
path: 'webauthn', path: 'webauthn',
loadChildren: () => loadChildren: () =>
@ -104,6 +99,11 @@ const routes: Routes = [
(m) => m.WebauthnPageModule (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 // wildcard, if requested url doesn't match any paths for routes defined
// earlier // earlier

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

@ -1,9 +1,4 @@
<mat-toolbar class="p-0"> <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"> <ng-container *ngIf="user">
<a [routerLink]="['/']" class="no-min-width px-2" mat-button> <a [routerLink]="['/']" class="no-min-width px-2" mat-button>
<gf-logo></gf-logo> <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 { ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service'; import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service';
import { WebAuthnService } from '@ghostfolio/client/services/web-authn.service'; import { WebAuthnService } from '@ghostfolio/client/services/web-authn.service';
import { Router } from '@angular/router';
@Component({ @Component({
selector: 'gf-webauthn-page', selector: 'gf-webauthn-page',
@ -18,14 +18,14 @@ export class WebauthnPageComponent implements OnInit {
private webAuthnService: WebAuthnService private webAuthnService: WebAuthnService
) {} ) {}
ngOnInit(): void { public ngOnInit() {
this.signIn(); this.signIn();
} }
public deregisterDevice() { public deregisterDevice() {
this.webAuthnService this.webAuthnService.deregister().subscribe(() => {
.deregister() this.router.navigate(['/']);
.subscribe(() => this.router.navigate([''])); });
} }
public signIn() { public signIn() {
@ -34,7 +34,7 @@ export class WebauthnPageComponent implements OnInit {
this.webAuthnService.login().subscribe( this.webAuthnService.login().subscribe(
({ authToken }) => { ({ authToken }) => {
this.tokenStorageService.saveToken(authToken, false); this.tokenStorageService.saveToken(authToken, false);
this.router.navigate(['']); this.router.navigate(['/']);
}, },
(error) => { (error) => {
console.error(error); console.error(error);

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

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

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

@ -1,19 +1,19 @@
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core'; 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 { 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({ @NgModule({
declarations: [WebauthnPageComponent], declarations: [WebauthnPageComponent],
exports: [], exports: [],
imports: [ imports: [
WebauthnPageRoutingModule,
CommonModule, CommonModule,
MatButtonModule, MatButtonModule,
MatProgressSpinnerModule MatProgressSpinnerModule,
WebauthnPageRoutingModule
], ],
providers: [] providers: []
}) })

Loading…
Cancel
Save