option to disable change password notification

This commit is contained in:
Kyle Spearrin 2018-07-31 23:48:11 -04:00
parent cf57eadd1d
commit 4076247908
5 changed files with 53 additions and 19 deletions

View File

@ -485,6 +485,12 @@
"notificationNeverSave": { "notificationNeverSave": {
"message": "Never for this website" "message": "Never for this website"
}, },
"disableChangedPasswordNotification": {
"message": "Disable Changed Password Notification"
},
"disableChangedPasswordNotificationDesc": {
"message": "The \"Changed Password Notification\" automatically prompts you to update a login's password in your vault whenever it detects that you have changed it on a website."
},
"notificationChangeDesc": { "notificationChangeDesc": {
"message": "Do you want to update this password in Bitwarden?" "message": "Do you want to update this password in Bitwarden?"
}, },

View File

@ -200,6 +200,7 @@ export default class RuntimeBackground {
} }
this.main.notificationQueue.splice(i, 1); this.main.notificationQueue.splice(i, 1);
BrowserApi.tabSendMessageData(tab, 'closeNotificationBar');
const loginModel = new LoginView(); const loginModel = new LoginView();
const loginUri = new LoginUriView(); const loginUri = new LoginUriView();
@ -218,8 +219,6 @@ export default class RuntimeBackground {
hitType: 'event', hitType: 'event',
eventAction: 'Added Login from Notification Bar', eventAction: 'Added Login from Notification Bar',
}); });
BrowserApi.tabSendMessageData(tab, 'closeNotificationBar');
} }
} }
@ -236,6 +235,7 @@ export default class RuntimeBackground {
} }
this.main.notificationQueue.splice(i, 1); this.main.notificationQueue.splice(i, 1);
BrowserApi.tabSendMessageData(tab, 'closeNotificationBar');
const cipher = await this.cipherService.get(queueMessage.cipherId); const cipher = await this.cipherService.get(queueMessage.cipherId);
if (cipher != null && cipher.type === CipherType.Login) { if (cipher != null && cipher.type === CipherType.Login) {
@ -248,8 +248,6 @@ export default class RuntimeBackground {
eventAction: 'Changed Password from Notification Bar', eventAction: 'Changed Password from Notification Bar',
}); });
} }
BrowserApi.tabSendMessageData(tab, 'closeNotificationBar');
} }
} }
@ -266,9 +264,10 @@ export default class RuntimeBackground {
} }
this.main.notificationQueue.splice(i, 1); this.main.notificationQueue.splice(i, 1);
BrowserApi.tabSendMessageData(tab, 'closeNotificationBar');
const hostname = Utils.getHostname(tab.url); const hostname = Utils.getHostname(tab.url);
await this.cipherService.saveNeverDomain(hostname); await this.cipherService.saveNeverDomain(hostname);
BrowserApi.tabSendMessageData(tab, 'closeNotificationBar');
} }
} }
@ -418,8 +417,10 @@ export default class RuntimeBackground {
const responseData: any = {}; const responseData: any = {};
if (responseCommand === 'notificationBarDataResponse') { if (responseCommand === 'notificationBarDataResponse') {
responseData.neverDomains = await this.storageService.get<any>(ConstantsService.neverDomainsKey); responseData.neverDomains = await this.storageService.get<any>(ConstantsService.neverDomainsKey);
responseData.disabledNotification = await this.storageService.get<boolean>( responseData.disabledAddLoginNotification = await this.storageService.get<boolean>(
ConstantsService.disableAddLoginNotificationKey); ConstantsService.disableAddLoginNotificationKey);
responseData.disabledChangedPasswordNotification = await this.storageService.get<boolean>(
ConstantsService.disableChangedPasswordNotificationKey);
} else if (responseCommand === 'autofillerAutofillOnPageLoadEnabledResponse') { } else if (responseCommand === 'autofillerAutofillOnPageLoadEnabledResponse') {
responseData.autofillEnabled = await this.storageService.get<boolean>( responseData.autofillEnabled = await this.storageService.get<boolean>(
ConstantsService.enableAutoFillOnPageLoadKey); ConstantsService.enableAutoFillOnPageLoadKey);

View File

@ -17,6 +17,8 @@ document.addEventListener('DOMContentLoaded', (event) => {
let notificationBarData = null; let notificationBarData = null;
const isSafari = (typeof safari !== 'undefined') && navigator.userAgent.indexOf(' Safari/') !== -1 && const isSafari = (typeof safari !== 'undefined') && navigator.userAgent.indexOf(' Safari/') !== -1 &&
navigator.userAgent.indexOf('Chrome') === -1; navigator.userAgent.indexOf('Chrome') === -1;
let disabledAddLoginNotification = false;
let disabledChangedPasswordNotification = false;
if (isSafari) { if (isSafari) {
if (inIframe) { if (inIframe) {
@ -37,12 +39,11 @@ document.addEventListener('DOMContentLoaded', (event) => {
return; return;
} }
if (notificationBarData.disabledNotification === true) { disabledAddLoginNotification = notificationBarData.disabledAddLoginNotification === true;
return; disabledChangedPasswordNotification = notificationBarData.disabledChangedPasswordNotification === true;
if (!disabledAddLoginNotification || !disabledChangedPasswordNotification) {
collectIfNeededWithTimeout();
} }
collectIfNeededWithTimeout();
return;
} }
processMessages(msg, () => { /* do nothing on send response for Safari */ }); processMessages(msg, () => { /* do nothing on send response for Safari */ });
@ -55,10 +56,15 @@ document.addEventListener('DOMContentLoaded', (event) => {
return; return;
} }
chrome.storage.local.get('disableAddLoginNotification', (disObj: any) => { chrome.storage.local.get('disableAddLoginNotification', (disAddObj: any) => {
if (disObj == null || !disObj.disableAddLoginNotification) { disabledAddLoginNotification = disAddObj != null && disAddObj.disableAddLoginNotification === true;
collectIfNeededWithTimeout(); chrome.storage.local.get('disableChangedPasswordNotification', (disChangedObj: any) => {
} disabledChangedPasswordNotification = disChangedObj != null &&
disChangedObj.disableChangedPasswordNotification === true;
if (!disabledAddLoginNotification || !disabledChangedPasswordNotification) {
collectIfNeededWithTimeout();
}
});
}); });
}); });
@ -334,7 +340,7 @@ document.addEventListener('DOMContentLoaded', (event) => {
if (formData[i].formEl !== form) { if (formData[i].formEl !== form) {
continue; continue;
} }
if (formData[i].usernameEl != null && formData[i].passwordEl != null) { if (!disabledAddLoginNotification && formData[i].usernameEl != null && formData[i].passwordEl != null) {
const login = { const login = {
username: formData[i].usernameEl.value, username: formData[i].usernameEl.value,
password: formData[i].passwordEl.value, password: formData[i].passwordEl.value,
@ -351,7 +357,8 @@ document.addEventListener('DOMContentLoaded', (event) => {
break; break;
} }
} }
if (formData[i].passwordEls != null && formData[i].passwordEls.length === 3) { if (!disabledChangedPasswordNotification && formData[i].passwordEls != null &&
formData[i].passwordEls.length === 3) {
const passwords = formData[i].passwordEls const passwords = formData[i].passwordEls
.filter((el: HTMLInputElement) => el.value != null && el.value !== '') .filter((el: HTMLInputElement) => el.value != null && el.value !== '')
.map((el: HTMLInputElement) => el.value); .map((el: HTMLInputElement) => el.value);

View File

@ -45,13 +45,23 @@
<div class="box"> <div class="box">
<div class="box-content"> <div class="box-content">
<div class="box-content-row box-content-row-checkbox" appBoxRow> <div class="box-content-row box-content-row-checkbox" appBoxRow>
<label for="notification-bar">{{'disableAddLoginNotification' | i18n}}</label> <label for="addlogin-notification-bar">{{'disableAddLoginNotification' | i18n}}</label>
<input id="notification-bar" type="checkbox" (change)="updateAddLoginNotification()" <input id="addlogin-notification-bar" type="checkbox" (change)="updateAddLoginNotification()"
[(ngModel)]="disableAddLoginNotification"> [(ngModel)]="disableAddLoginNotification">
</div> </div>
</div> </div>
<div class="box-footer">{{'addLoginNotificationDesc' | i18n}}</div> <div class="box-footer">{{'addLoginNotificationDesc' | i18n}}</div>
</div> </div>
<div class="box">
<div class="box-content">
<div class="box-content-row box-content-row-checkbox" appBoxRow>
<label for="changedpass-notification-bar">{{'disableChangedPasswordNotification' | i18n}}</label>
<input id="changedpass-notification-bar" type="checkbox" (change)="updateChangedPasswordNotification()"
[(ngModel)]="disableChangedPasswordNotification">
</div>
</div>
<div class="box-footer">{{'disableChangedPasswordNotificationDesc' | i18n}}</div>
</div>
<div class="box" *ngIf="showDisableContextMenu"> <div class="box" *ngIf="showDisableContextMenu">
<div class="box-content"> <div class="box-content">
<div class="box-content-row box-content-row-checkbox" appBoxRow> <div class="box-content-row box-content-row-checkbox" appBoxRow>

View File

@ -24,6 +24,7 @@ export class OptionsComponent implements OnInit {
disableAutoTotpCopy = false; disableAutoTotpCopy = false;
disableContextMenuItem = false; disableContextMenuItem = false;
disableAddLoginNotification = false; disableAddLoginNotification = false;
disableChangedPasswordNotification = false;
showDisableContextMenu = true; showDisableContextMenu = true;
disableGa = false; disableGa = false;
theme: string; theme: string;
@ -53,6 +54,9 @@ export class OptionsComponent implements OnInit {
this.disableAddLoginNotification = await this.storageService.get<boolean>( this.disableAddLoginNotification = await this.storageService.get<boolean>(
ConstantsService.disableAddLoginNotificationKey); ConstantsService.disableAddLoginNotificationKey);
this.disableChangedPasswordNotification = await this.storageService.get<boolean>(
ConstantsService.disableChangedPasswordNotificationKey);
this.disableContextMenuItem = await this.storageService.get<boolean>( this.disableContextMenuItem = await this.storageService.get<boolean>(
ConstantsService.disableContextMenuItemKey); ConstantsService.disableContextMenuItemKey);
@ -79,6 +83,12 @@ export class OptionsComponent implements OnInit {
this.callAnalytics('Add Login Notification', !this.disableAddLoginNotification); this.callAnalytics('Add Login Notification', !this.disableAddLoginNotification);
} }
async updateChangedPasswordNotification() {
await this.storageService.save(ConstantsService.disableChangedPasswordNotificationKey,
this.disableChangedPasswordNotification);
this.callAnalytics('Changed Password Notification', !this.disableChangedPasswordNotification);
}
async updateDisableContextMenuItem() { async updateDisableContextMenuItem() {
await this.storageService.save(ConstantsService.disableContextMenuItemKey, await this.storageService.save(ConstantsService.disableContextMenuItemKey,
this.disableContextMenuItem); this.disableContextMenuItem);