Open login prompt as popout when vault is locked

This commit is contained in:
Daniel James Smith 2021-09-30 16:33:33 +02:00
parent 642af32c89
commit 5c175e2201
No known key found for this signature in database
GPG Key ID: 03E4BD365FF06726
3 changed files with 28 additions and 6 deletions

View File

@ -240,7 +240,7 @@ export default class MainBackground {
this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService, this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService,
this.platformUtilsService as BrowserPlatformUtilsService, this.storageService, this.i18nService, this.platformUtilsService as BrowserPlatformUtilsService, this.storageService, this.i18nService,
this.notificationsService, this.systemService, this.vaultTimeoutService, this.notificationsService, this.systemService, this.vaultTimeoutService,
this.environmentService, this.policyService, this.userService, this.messagingService, this.folderService); this.environmentService, this.policyService, this.userService, this.messagingService, this.folderService, this.popupUtilsService);
this.nativeMessagingBackground = new NativeMessagingBackground(this.storageService, this.cryptoService, this.cryptoFunctionService, this.nativeMessagingBackground = new NativeMessagingBackground(this.storageService, this.cryptoService, this.cryptoFunctionService,
this.vaultTimeoutService, this.runtimeBackground, this.i18nService, this.userService, this.messagingService, this.appIdService, this.vaultTimeoutService, this.runtimeBackground, this.i18nService, this.userService, this.messagingService, this.appIdService,
this.platformUtilsService); this.platformUtilsService);

View File

@ -16,6 +16,7 @@ import { SystemService } from 'jslib-common/abstractions/system.service';
import { UserService } from 'jslib-common/abstractions/user.service'; import { UserService } from 'jslib-common/abstractions/user.service';
import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.service'; import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.service';
import { ConstantsService } from 'jslib-common/services/constants.service'; import { ConstantsService } from 'jslib-common/services/constants.service';
import { PopupUtilsService } from '../popup/services/popup-utils.service';
import { AutofillService } from '../services/abstractions/autofill.service'; import { AutofillService } from '../services/abstractions/autofill.service';
import BrowserPlatformUtilsService from '../services/browserPlatformUtils.service'; import BrowserPlatformUtilsService from '../services/browserPlatformUtils.service';
@ -43,7 +44,7 @@ export default class RuntimeBackground {
private systemService: SystemService, private vaultTimeoutService: VaultTimeoutService, private systemService: SystemService, private vaultTimeoutService: VaultTimeoutService,
private environmentService: EnvironmentService, private policyService: PolicyService, private environmentService: EnvironmentService, private policyService: PolicyService,
private userService: UserService, private messagingService: MessagingService, private userService: UserService, private messagingService: MessagingService,
private folderService: FolderService) { private folderService: FolderService, private popupUtilsService: PopupUtilsService) {
// onInstalled listener must be wired up before anything else, so we do it in the ctor // onInstalled listener must be wired up before anything else, so we do it in the ctor
chrome.runtime.onInstalled.addListener((details: any) => { chrome.runtime.onInstalled.addListener((details: any) => {
@ -82,6 +83,9 @@ export default class RuntimeBackground {
case 'openPopup': case 'openPopup':
await this.main.openPopup(); await this.main.openPopup();
break; break;
case 'openPopout':
await this.popupUtilsService.popOut(window, 'popup/index.html?uilocation=popout');
break;
case 'showDialogResolve': case 'showDialogResolve':
this.platformUtilsService.resolveDialogPromise(msg.dialogId, msg.confirmed); this.platformUtilsService.resolveDialogPromise(msg.dialogId, msg.confirmed);
break; break;

View File

@ -61,11 +61,21 @@ document.addEventListener('DOMContentLoaded', () => {
addButton.addEventListener('click', (e) => { addButton.addEventListener('click', (e) => {
e.preventDefault(); e.preventDefault();
const folderId = document.querySelector('#template-add-clone .select-folder').value; const folderId = document.querySelector('#template-add-clone .select-folder').value;
sendPlatformMessage({
const bgAddSaveMessage = {
command: 'bgAddSave', command: 'bgAddSave',
folder: folderId, folder: folderId,
};
if (isVaultLocked) {
sendPlatformMessage({
command: 'openPopout'
}); });
}
sendPlatformMessage(bgAddSaveMessage);
}); });
neverButton.addEventListener('click', (e) => { neverButton.addEventListener('click', (e) => {
@ -92,9 +102,17 @@ document.addEventListener('DOMContentLoaded', () => {
var changeButton = document.querySelector('#template-change-clone .change-save'); var changeButton = document.querySelector('#template-change-clone .change-save');
changeButton.addEventListener('click', (e) => { changeButton.addEventListener('click', (e) => {
e.preventDefault(); e.preventDefault();
sendPlatformMessage({
const bgChangeSaveMessage = {
command: 'bgChangeSave' command: 'bgChangeSave'
};
if (isVaultLocked) {
sendPlatformMessage({
command: 'openPopout'
}); });
}
sendPlatformMessage(bgChangeSaveMessage);
}); });
} else if (getQueryVariable('info')) { } else if (getQueryVariable('info')) {
setContent(document.getElementById('template-alert')); setContent(document.getElementById('template-alert'));