|
@ -23,7 +23,7 @@ import { MatSlideToggleChange } from '@angular/material/slide-toggle'; |
|
|
import { MatSnackBar } from '@angular/material/snack-bar'; |
|
|
import { MatSnackBar } from '@angular/material/snack-bar'; |
|
|
import { format, parseISO } from 'date-fns'; |
|
|
import { format, parseISO } from 'date-fns'; |
|
|
import { uniq } from 'lodash'; |
|
|
import { uniq } from 'lodash'; |
|
|
import { EMPTY, Subject } from 'rxjs'; |
|
|
import { EMPTY, Subject, throwError } from 'rxjs'; |
|
|
import { catchError, takeUntil } from 'rxjs/operators'; |
|
|
import { catchError, takeUntil } from 'rxjs/operators'; |
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
@ -43,7 +43,7 @@ export class UserAccountSettingsComponent implements OnDestroy, OnInit { |
|
|
public hasPermissionToUpdateViewMode: boolean; |
|
|
public hasPermissionToUpdateViewMode: boolean; |
|
|
public hasPermissionToUpdateUserSettings: boolean; |
|
|
public hasPermissionToUpdateUserSettings: boolean; |
|
|
public isAccessTokenHidden = true; |
|
|
public isAccessTokenHidden = true; |
|
|
public isFingerprintSupported: boolean; |
|
|
public isFingerprintSupported = this.doesBrowserSupportAuthn(); |
|
|
public isWebAuthnEnabled: boolean; |
|
|
public isWebAuthnEnabled: boolean; |
|
|
public language = document.documentElement.lang; |
|
|
public language = document.documentElement.lang; |
|
|
public locales = [ |
|
|
public locales = [ |
|
@ -69,9 +69,9 @@ export class UserAccountSettingsComponent implements OnDestroy, OnInit { |
|
|
private dataService: DataService, |
|
|
private dataService: DataService, |
|
|
private formBuilder: FormBuilder, |
|
|
private formBuilder: FormBuilder, |
|
|
private settingsStorageService: SettingsStorageService, |
|
|
private settingsStorageService: SettingsStorageService, |
|
|
|
|
|
private snackBar: MatSnackBar, |
|
|
private tokenStorageService: TokenStorageService, |
|
|
private tokenStorageService: TokenStorageService, |
|
|
private userService: UserService, |
|
|
private userService: UserService, |
|
|
private snackBar: MatSnackBar, |
|
|
|
|
|
public webAuthnService: WebAuthnService |
|
|
public webAuthnService: WebAuthnService |
|
|
) { |
|
|
) { |
|
|
const { baseCurrency, currencies } = this.dataService.fetchInfo(); |
|
|
const { baseCurrency, currencies } = this.dataService.fetchInfo(); |
|
@ -228,7 +228,10 @@ export class UserAccountSettingsComponent implements OnDestroy, OnInit { |
|
|
|
|
|
|
|
|
public onSignInWithFingerprintChange(aEvent: MatSlideToggleChange) { |
|
|
public onSignInWithFingerprintChange(aEvent: MatSlideToggleChange) { |
|
|
if (aEvent.checked) { |
|
|
if (aEvent.checked) { |
|
|
this.registerDevice(aEvent); |
|
|
this.registerDevice().catch(() => { |
|
|
|
|
|
aEvent.source.checked = false; |
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
|
|
|
}); |
|
|
} else { |
|
|
} else { |
|
|
const confirmation = confirm( |
|
|
const confirmation = confirm( |
|
|
$localize`Do you really want to remove this sign in method?` |
|
|
$localize`Do you really want to remove this sign in method?` |
|
@ -281,15 +284,13 @@ export class UserAccountSettingsComponent implements OnDestroy, OnInit { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private registerDevice(aEvent: MatSlideToggleChange) { |
|
|
private registerDevice(): Promise<void> { |
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
this.webAuthnService |
|
|
this.webAuthnService |
|
|
.register() |
|
|
.register() |
|
|
.pipe( |
|
|
.pipe( |
|
|
takeUntil(this.unsubscribeSubject), |
|
|
takeUntil(this.unsubscribeSubject), |
|
|
catchError((error: Error) => { |
|
|
catchError((error: Error) => { |
|
|
aEvent.source.checked = false; |
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
|
|
|
|
|
|
|
|
|
let errorMessage: string; |
|
|
let errorMessage: string; |
|
|
|
|
|
|
|
|
if ( |
|
|
if ( |
|
@ -302,18 +303,23 @@ export class UserAccountSettingsComponent implements OnDestroy, OnInit { |
|
|
errorMessage = $localize`Oops! There was an unknown error setting up biometric authentication.`; |
|
|
errorMessage = $localize`Oops! There was an unknown error setting up biometric authentication.`; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.snackBar.open(errorMessage, undefined, { |
|
|
this.snackBar.open(errorMessage, undefined, { duration: 4000 }); |
|
|
duration: 4000 |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return EMPTY; |
|
|
return throwError(() => error); |
|
|
}) |
|
|
}) |
|
|
) |
|
|
) |
|
|
.subscribe(() => { |
|
|
.subscribe({ |
|
|
|
|
|
next: () => { |
|
|
this.settingsStorageService.removeSetting(KEY_STAY_SIGNED_IN); |
|
|
this.settingsStorageService.removeSetting(KEY_STAY_SIGNED_IN); |
|
|
this.settingsStorageService.removeSetting(KEY_TOKEN); |
|
|
this.settingsStorageService.removeSetting(KEY_TOKEN); |
|
|
|
|
|
|
|
|
this.update(); |
|
|
this.update(); |
|
|
|
|
|
resolve(); |
|
|
|
|
|
}, |
|
|
|
|
|
error: (error) => { |
|
|
|
|
|
reject(error); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|