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

View File

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

View File

@ -45,13 +45,23 @@
<div class="box">
<div class="box-content">
<div class="box-content-row box-content-row-checkbox" appBoxRow>
<label for="notification-bar">{{'disableAddLoginNotification' | i18n}}</label>
<input id="notification-bar" type="checkbox" (change)="updateAddLoginNotification()"
<label for="addlogin-notification-bar">{{'disableAddLoginNotification' | i18n}}</label>
<input id="addlogin-notification-bar" type="checkbox" (change)="updateAddLoginNotification()"
[(ngModel)]="disableAddLoginNotification">
</div>
</div>
<div class="box-footer">{{'addLoginNotificationDesc' | i18n}}</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-content">
<div class="box-content-row box-content-row-checkbox" appBoxRow>

View File

@ -24,6 +24,7 @@ export class OptionsComponent implements OnInit {
disableAutoTotpCopy = false;
disableContextMenuItem = false;
disableAddLoginNotification = false;
disableChangedPasswordNotification = false;
showDisableContextMenu = true;
disableGa = false;
theme: string;
@ -53,6 +54,9 @@ export class OptionsComponent implements OnInit {
this.disableAddLoginNotification = await this.storageService.get<boolean>(
ConstantsService.disableAddLoginNotificationKey);
this.disableChangedPasswordNotification = await this.storageService.get<boolean>(
ConstantsService.disableChangedPasswordNotificationKey);
this.disableContextMenuItem = await this.storageService.get<boolean>(
ConstantsService.disableContextMenuItemKey);
@ -79,6 +83,12 @@ export class OptionsComponent implements OnInit {
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() {
await this.storageService.save(ConstantsService.disableContextMenuItemKey,
this.disableContextMenuItem);