From 2aa71f98a1f623470b3bd71306e0ef8a1ba97758 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 2 Jul 2019 08:13:33 -0400 Subject: [PATCH] re-set favicon state after unlock/login --- src/angular/components/lock.component.ts | 7 +++++-- src/angular/components/login.component.ts | 7 ++++++- src/angular/components/two-factor.component.ts | 8 +++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/angular/components/lock.component.ts b/src/angular/components/lock.component.ts index b8d238253dd..a5357f897fd 100644 --- a/src/angular/components/lock.component.ts +++ b/src/angular/components/lock.component.ts @@ -7,6 +7,7 @@ import { I18nService } from '../../abstractions/i18n.service'; import { LockService } from '../../abstractions/lock.service'; import { MessagingService } from '../../abstractions/messaging.service'; import { PlatformUtilsService } from '../../abstractions/platformUtils.service'; +import { StateService } from '../../abstractions/state.service'; import { StorageService } from '../../abstractions/storage.service'; import { UserService } from '../../abstractions/user.service'; @@ -35,7 +36,7 @@ export class LockComponent implements OnInit { protected platformUtilsService: PlatformUtilsService, protected messagingService: MessagingService, protected userService: UserService, protected cryptoService: CryptoService, protected storageService: StorageService, protected lockService: LockService, - protected environmentService: EnvironmentService) { } + protected environmentService: EnvironmentService, protected stateService: StateService) { } async ngOnInit() { this.pinSet = await this.lockService.isPinLockSet(); @@ -126,7 +127,9 @@ export class LockComponent implements OnInit { this.doContinue(); } - private doContinue() { + private async doContinue() { + const disableFavicon = await this.storageService.get(ConstantsService.disableFaviconKey); + await this.stateService.save(ConstantsService.disableFaviconKey, !!disableFavicon); this.messagingService.send('unlocked'); if (this.onSuccessfulSubmit != null) { this.onSuccessfulSubmit(); diff --git a/src/angular/components/login.component.ts b/src/angular/components/login.component.ts index 86e0e66a7cb..2c41e01533e 100644 --- a/src/angular/components/login.component.ts +++ b/src/angular/components/login.component.ts @@ -9,8 +9,11 @@ import { AuthResult } from '../../models/domain/authResult'; import { AuthService } from '../../abstractions/auth.service'; import { I18nService } from '../../abstractions/i18n.service'; import { PlatformUtilsService } from '../../abstractions/platformUtils.service'; +import { StateService } from '../../abstractions/state.service'; import { StorageService } from '../../abstractions/storage.service'; +import { ConstantsService } from '../../services/constants.service'; + import { Utils } from '../../misc/utils'; const Keys = { @@ -34,7 +37,7 @@ export class LoginComponent implements OnInit { constructor(protected authService: AuthService, protected router: Router, protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService, - private storageService: StorageService) { } + private storageService: StorageService, private stateService: StorageService) { } async ngOnInit() { if (this.email == null || this.email === '') { @@ -86,6 +89,8 @@ export class LoginComponent implements OnInit { this.router.navigate([this.twoFactorRoute]); } } else { + const disableFavicon = await this.storageService.get(ConstantsService.disableFaviconKey); + await this.stateService.save(ConstantsService.disableFaviconKey, !!disableFavicon); if (this.onSuccessfulLogin != null) { this.onSuccessfulLogin(); } diff --git a/src/angular/components/two-factor.component.ts b/src/angular/components/two-factor.component.ts index 1e3ccd8904f..dd460a16c55 100644 --- a/src/angular/components/two-factor.component.ts +++ b/src/angular/components/two-factor.component.ts @@ -14,8 +14,11 @@ import { AuthService } from '../../abstractions/auth.service'; import { EnvironmentService } from '../../abstractions/environment.service'; import { I18nService } from '../../abstractions/i18n.service'; import { PlatformUtilsService } from '../../abstractions/platformUtils.service'; +import { StateService } from '../../abstractions/state.service'; +import { StorageService } from '../../abstractions/storage.service'; import { TwoFactorProviders } from '../../services/auth.service'; +import { ConstantsService } from '../../services/constants.service'; import * as DuoWebSDK from 'duo_web_sdk'; import { U2f } from '../../misc/u2f'; @@ -42,7 +45,8 @@ export class TwoFactorComponent implements OnInit, OnDestroy { constructor(protected authService: AuthService, protected router: Router, protected i18nService: I18nService, protected apiService: ApiService, protected platformUtilsService: PlatformUtilsService, protected win: Window, - protected environmentService: EnvironmentService) { + protected environmentService: EnvironmentService, protected stateService: StateService, + protected storageService: StorageService) { this.u2fSupported = this.platformUtilsService.supportsU2f(win); } @@ -169,6 +173,8 @@ export class TwoFactorComponent implements OnInit, OnDestroy { try { this.formPromise = this.authService.logInTwoFactor(this.selectedProviderType, this.token, this.remember); await this.formPromise; + const disableFavicon = await this.storageService.get(ConstantsService.disableFaviconKey); + await this.stateService.save(ConstantsService.disableFaviconKey, !!disableFavicon); if (this.onSuccessfulLogin != null) { this.onSuccessfulLogin(); }