mirror of https://github.com/ghostfolio/ghostfolio
Browse Source
* Restrict webauthn to fingerprint only * Move webauthn login to separate page /webauthn * Stay signed in with social login * Update changelog Co-authored-by: Thomas <4159106+dtslvr@users.noreply.github.com>pull/162/head
Matthias Frey
4 years ago
committed by
GitHub
17 changed files with 164 additions and 27 deletions
@ -0,0 +1,11 @@ |
|||
import { NgModule } from '@angular/core'; |
|||
import { RouterModule, Routes } from '@angular/router'; |
|||
import { WebauthnPageComponent } from '@ghostfolio/client/pages/webauthn/webauthn-page.component'; |
|||
|
|||
const routes: Routes = [{ path: '', component: WebauthnPageComponent }]; |
|||
|
|||
@NgModule({ |
|||
imports: [RouterModule.forChild(routes)], |
|||
exports: [RouterModule] |
|||
}) |
|||
export class WebauthnPageRoutingModule {} |
@ -0,0 +1,46 @@ |
|||
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'; |
|||
|
|||
@Component({ |
|||
selector: 'gf-webauthn-page', |
|||
templateUrl: './webauthn-page.html', |
|||
styleUrls: ['./webauthn-page.scss'] |
|||
}) |
|||
export class WebauthnPageComponent implements OnInit { |
|||
public hasError = false; |
|||
|
|||
constructor( |
|||
private changeDetectorRef: ChangeDetectorRef, |
|||
private router: Router, |
|||
private tokenStorageService: TokenStorageService, |
|||
private webAuthnService: WebAuthnService |
|||
) {} |
|||
|
|||
public ngOnInit() { |
|||
this.signIn(); |
|||
} |
|||
|
|||
public deregisterDevice() { |
|||
this.webAuthnService.deregister().subscribe(() => { |
|||
this.router.navigate(['/']); |
|||
}); |
|||
} |
|||
|
|||
public signIn() { |
|||
this.hasError = false; |
|||
|
|||
this.webAuthnService.login().subscribe( |
|||
({ authToken }) => { |
|||
this.tokenStorageService.saveToken(authToken, false); |
|||
this.router.navigate(['/']); |
|||
}, |
|||
(error) => { |
|||
console.error(error); |
|||
this.hasError = true; |
|||
this.changeDetectorRef.markForCheck(); |
|||
} |
|||
); |
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
<div class="container"> |
|||
<div class="row"> |
|||
<div *ngIf="!hasError" class="col d-flex justify-content-center"> |
|||
<mat-spinner [diameter]="20"></mat-spinner> |
|||
</div> |
|||
<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="my-4" |
|||
color="primary" |
|||
i18n |
|||
mat-flat-button |
|||
> |
|||
Try again |
|||
</button> |
|||
<button (click)="deregisterDevice()" i18n mat-flat-button> |
|||
Go back to Home Page |
|||
</button> |
|||
</div> |
|||
</div> |
|||
</div> |
@ -0,0 +1,20 @@ |
|||
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'; |
|||
|
|||
@NgModule({ |
|||
declarations: [WebauthnPageComponent], |
|||
exports: [], |
|||
imports: [ |
|||
CommonModule, |
|||
MatButtonModule, |
|||
MatProgressSpinnerModule, |
|||
WebauthnPageRoutingModule |
|||
], |
|||
providers: [] |
|||
}) |
|||
export class WebauthnPageModule {} |
Loading…
Reference in new issue