From 833982a9de446f8785bedb5005b39dac4a4952cd Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Tue, 5 Dec 2023 18:13:35 +0100 Subject: [PATCH] Bugfix/fix biometric authentication registration (#2713) * Remove token on device registration * Update changelog --- CHANGELOG.md | 4 ++++ .../src/app/components/header/header.component.ts | 4 ++-- .../login-with-access-token-dialog.component.ts | 4 ++-- .../user-account-settings.component.ts | 6 ++++-- apps/client/src/app/pages/auth/auth-page.component.ts | 4 ++-- .../src/app/services/settings-storage.service.ts | 5 +++-- apps/client/src/app/services/token-storage.service.ts | 11 +++++------ 7 files changed, 22 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d6b4486e..fe3af1f46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Improved the language localization for Türkçe (`tr`) - Upgraded `ng-extract-i18n-merge` from version `2.8.3` to `2.9.0` +### Fixed + +- Fixed an issue in the biometric authentication registration + ## 2.28.0 - 2023-12-02 ### Added diff --git a/apps/client/src/app/components/header/header.component.ts b/apps/client/src/app/components/header/header.component.ts index 930c4910c..a1f65f244 100644 --- a/apps/client/src/app/components/header/header.component.ts +++ b/apps/client/src/app/components/header/header.component.ts @@ -15,7 +15,7 @@ import { LoginWithAccessTokenDialog } from '@ghostfolio/client/components/login- import { DataService } from '@ghostfolio/client/services/data.service'; import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; import { - STAY_SIGNED_IN, + KEY_STAY_SIGNED_IN, SettingsStorageService } from '@ghostfolio/client/services/settings-storage.service'; import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service'; @@ -196,7 +196,7 @@ export class HeaderComponent implements OnChanges { public setToken(aToken: string) { this.tokenStorageService.saveToken( aToken, - this.settingsStorageService.getSetting(STAY_SIGNED_IN) === 'true' + this.settingsStorageService.getSetting(KEY_STAY_SIGNED_IN) === 'true' ); this.router.navigate(['/']); diff --git a/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.component.ts b/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.component.ts index b3236b2be..9f9fdbabd 100644 --- a/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.component.ts +++ b/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.component.ts @@ -4,7 +4,7 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { Router } from '@angular/router'; import { InternetIdentityService } from '@ghostfolio/client/services/internet-identity.service'; import { - STAY_SIGNED_IN, + KEY_STAY_SIGNED_IN, SettingsStorageService } from '@ghostfolio/client/services/settings-storage.service'; import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service'; @@ -31,7 +31,7 @@ export class LoginWithAccessTokenDialog { public onChangeStaySignedIn(aValue: MatCheckboxChange) { this.settingsStorageService.setSetting( - STAY_SIGNED_IN, + KEY_STAY_SIGNED_IN, aValue.checked?.toString() ); } diff --git a/apps/client/src/app/components/user-account-settings/user-account-settings.component.ts b/apps/client/src/app/components/user-account-settings/user-account-settings.component.ts index 3a1e02596..eaf16e015 100644 --- a/apps/client/src/app/components/user-account-settings/user-account-settings.component.ts +++ b/apps/client/src/app/components/user-account-settings/user-account-settings.component.ts @@ -8,7 +8,8 @@ import { import { MatSlideToggleChange } from '@angular/material/slide-toggle'; import { DataService } from '@ghostfolio/client/services/data.service'; import { - STAY_SIGNED_IN, + KEY_STAY_SIGNED_IN, + KEY_TOKEN, SettingsStorageService } from '@ghostfolio/client/services/settings-storage.service'; import { UserService } from '@ghostfolio/client/services/user/user.service'; @@ -241,7 +242,8 @@ export class UserAccountSettingsComponent implements OnDestroy, OnInit { }) ) .subscribe(() => { - this.settingsStorageService.removeSetting(STAY_SIGNED_IN); + this.settingsStorageService.removeSetting(KEY_STAY_SIGNED_IN); + this.settingsStorageService.removeSetting(KEY_TOKEN); this.update(); }); diff --git a/apps/client/src/app/pages/auth/auth-page.component.ts b/apps/client/src/app/pages/auth/auth-page.component.ts index 75702c096..1dc494773 100644 --- a/apps/client/src/app/pages/auth/auth-page.component.ts +++ b/apps/client/src/app/pages/auth/auth-page.component.ts @@ -1,7 +1,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { - STAY_SIGNED_IN, + KEY_STAY_SIGNED_IN, SettingsStorageService } from '@ghostfolio/client/services/settings-storage.service'; import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service'; @@ -31,7 +31,7 @@ export class AuthPageComponent implements OnDestroy, OnInit { this.tokenStorageService.saveToken( jwt, - this.settingsStorageService.getSetting(STAY_SIGNED_IN) === 'true' + this.settingsStorageService.getSetting(KEY_STAY_SIGNED_IN) === 'true' ); this.router.navigate(['/']); diff --git a/apps/client/src/app/services/settings-storage.service.ts b/apps/client/src/app/services/settings-storage.service.ts index a340f89b7..abb49ea2d 100644 --- a/apps/client/src/app/services/settings-storage.service.ts +++ b/apps/client/src/app/services/settings-storage.service.ts @@ -1,7 +1,8 @@ import { Injectable } from '@angular/core'; -export const RANGE = 'range'; -export const STAY_SIGNED_IN = 'staySignedIn'; +export const KEY_RANGE = 'range'; +export const KEY_STAY_SIGNED_IN = 'staySignedIn'; +export const KEY_TOKEN = 'auth-token'; @Injectable({ providedIn: 'root' diff --git a/apps/client/src/app/services/token-storage.service.ts b/apps/client/src/app/services/token-storage.service.ts index 5980f56e1..b6af7350f 100644 --- a/apps/client/src/app/services/token-storage.service.ts +++ b/apps/client/src/app/services/token-storage.service.ts @@ -1,10 +1,9 @@ import { Injectable } from '@angular/core'; import { WebAuthnService } from '@ghostfolio/client/services/web-authn.service'; +import { KEY_TOKEN } from './settings-storage.service'; import { UserService } from './user/user.service'; -const TOKEN_KEY = 'auth-token'; - @Injectable({ providedIn: 'root' }) @@ -16,16 +15,16 @@ export class TokenStorageService { public getToken(): string { return ( - window.sessionStorage.getItem(TOKEN_KEY) || - window.localStorage.getItem(TOKEN_KEY) + window.sessionStorage.getItem(KEY_TOKEN) || + window.localStorage.getItem(KEY_TOKEN) ); } public saveToken(token: string, staySignedIn = false): void { if (staySignedIn) { - window.localStorage.setItem(TOKEN_KEY, token); + window.localStorage.setItem(KEY_TOKEN, token); } - window.sessionStorage.setItem(TOKEN_KEY, token); + window.sessionStorage.setItem(KEY_TOKEN, token); } public signOut(): void {