1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 02:03:39 +00:00

[macOS] Don't enable secure input when app is not in focus (#970)

* Don't engage macOS secure input if not focused

* Refactor to use focusInputOnPageLoad

* Fix style and linting

* Refactor to remove focusOnPageLoad

* Update jslib
This commit is contained in:
Thomas Rittson
2021-07-05 08:06:24 +10:00
committed by GitHub
parent 6d8fbf1e43
commit 3aa171a664
5 changed files with 49 additions and 4 deletions

View File

@@ -15,6 +15,7 @@ import { AuthService } from 'jslib-common/abstractions/auth.service';
import { CryptoFunctionService } from 'jslib-common/abstractions/cryptoFunction.service';
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { StateService } from 'jslib-common/abstractions/state.service';
@@ -37,12 +38,15 @@ export class LoginComponent extends BaseLoginComponent implements OnDestroy {
showingModal = false;
private deferFocus: boolean = null;
constructor(authService: AuthService, router: Router, i18nService: I18nService,
syncService: SyncService, private componentFactoryResolver: ComponentFactoryResolver,
platformUtilsService: PlatformUtilsService, stateService: StateService,
environmentService: EnvironmentService, passwordGenerationService: PasswordGenerationService,
cryptoFunctionService: CryptoFunctionService, storageService: StorageService,
private broadcasterService: BroadcasterService, private ngZone: NgZone) {
private broadcasterService: BroadcasterService, private ngZone: NgZone,
private messagingService: MessagingService) {
super(authService, router, platformUtilsService, i18nService, stateService, environmentService,
passwordGenerationService, cryptoFunctionService, storageService);
super.onSuccessfulLogin = () => {
@@ -58,10 +62,22 @@ export class LoginComponent extends BaseLoginComponent implements OnDestroy {
case 'windowHidden':
this.onWindowHidden();
break;
case 'windowIsFocused':
if (this.deferFocus === null) {
this.deferFocus = !message.windowIsFocused;
if (!this.deferFocus) {
this.focusInput();
}
} else if (this.deferFocus && message.windowIsFocused) {
this.focusInput();
this.deferFocus = false;
}
break;
default:
}
});
});
this.messagingService.send('getWindowIsFocused');
}
ngOnDestroy() {