#1487 Default excluded domain list update (Discourse problem) + button "Import default list" added

This commit is contained in:
Greg Zajac 2024-02-01 12:19:59 +01:00
parent 6f99c7e4d6
commit 30a8524f21
10 changed files with 125 additions and 12 deletions

View File

@ -69,6 +69,7 @@
36 - handleSafariReset
38 - storageValidationReload
45 - domainModalFormSubmit
47 - handleImportDefaultExcludedDomains
// PARTIALS
*23 - openShortcutEdit [redundant]

View File

@ -11,7 +11,8 @@
"optionsAddAnotherDevice": "Add another device",
"optionsExcludedDomainsHeader": "Auto submit excluded domains:",
"optionsRemoveFromExcluded": "Remove from excluded",
"optionsExcludeAnotherDomain": "Exclude another domain",
"optionsExcludeAnotherDomain": "Exclude domain",
"optionsExcludeImportDefault": "Import default list",
"optionsDomainModalHeader": "Exclude new domain",
"optionsDomainModalText": "With the form below, you can add your domain to exclusion list, ensuring it won't be subjected to the auto submit mechanism.",
"optionsDomainInputPlaceholder": "Type in domain to exclude...",

View File

@ -17,6 +17,17 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>
//
const defaultAutoSubmitExcludedDomains = [];
const defaultAutoSubmitExcludedDomains = [
// Discourse problem
// https://github.com/twofas/2fas-browser-extension/issues/42
// https://meta.discourse.org/t/totp-modal-problem-cooperation-with-2fas-browser-extension/293760
'community.bitwarden.com',
'forum.torproject.org',
'community.home-assistant.io',
'meta.discourse.org',
'forum.mssociety.org.uk',
'forum.asana.com',
'dev.epicgames.com'
];
module.exports = defaultAutoSubmitExcludedDomains;

View File

@ -0,0 +1,31 @@
const { loadFromLocalStorage, saveToLocalStorage } = require('../../localStorage');
const defaultAutoSubmitExcludedDomains = require('../../defaultAutoSubmitExcludedDomains');
const uniqueOnly = require('../../partials/uniqueOnly');
const generateDomainsList = require('./generateDomainsList');
const TwoFasNotification = require('../../notification');
const config = require('../../config');
const storeLog = require('../../partials/storeLog');
const handleImportDefaultExcludedDomains = e => {
e.preventDefault();
e.stopPropagation();
return loadFromLocalStorage(['autoSubmitExcludedDomains'])
.then(data => {
const currentExcludedDomains = data.autoSubmitExcludedDomains;
let newExcludedDomains = [...currentExcludedDomains, ...defaultAutoSubmitExcludedDomains];
newExcludedDomains = newExcludedDomains.filter(uniqueOnly);
return saveToLocalStorage({ autoSubmitExcludedDomains: newExcludedDomains }, {});
})
.then(res => {
generateDomainsList(res.autoSubmitExcludedDomains);
TwoFasNotification.show(config.Texts.Success.DomainExcluded);
})
.catch(async err => {
await storeLog('error', 47, err, 'handleImportDefaultExcludedDomains');
return TwoFasNotification.show(config.Texts.Error.UndefinedError, null, true);
});
};
module.exports = handleImportDefaultExcludedDomains;

View File

@ -29,6 +29,7 @@ exports.generateShortcutLink = require('./generateShortcutLink');
exports.handleAdvancedHeaderClick = require('./handleAdvancedHeaderClick');
exports.handleContextMenuChange = require('./handleContextMenuChange');
exports.handleHamburgerClick = require('./handleHamburgerClick');
exports.handleImportDefaultExcludedDomains = require('./handleImportDefaultExcludedDomains');
exports.handleLoggingChange = require('./handleLoggingChange');
exports.handleMenuLink = require('./handleMenuLink');
exports.handlePinInfo = require('./handlePinInfo');
@ -50,6 +51,7 @@ exports.setExtNameUpdateForm = require('./setExtNameUpdateForm');
exports.setExtVersion = require('./setExtVersion');
exports.setPinInfoBtns = require('./setPinInfoBtns');
exports.setHamburger = require('./setHamburger');
exports.setImportDefaultExcludedDomains = require('./setImportDefaultExcludedDomains');
exports.setLoggingToggle = require('./setLoggingToggle');
exports.setMenuLinks = require('./setMenuLinks');
exports.setModalsListeners = require('./setModalsListeners');

View File

@ -0,0 +1,9 @@
const S = require('../../selectors');
const handleImportDefaultExcludedDomains = require('./handleImportDefaultExcludedDomains');
const setImportDefaultExcludedDomains = () => {
const importDefaultListBtn = document.querySelector(S.optionsPage.autoSubmit.importDefault);
importDefaultListBtn.addEventListener('click', handleImportDefaultExcludedDomains);
};
module.exports = setImportDefaultExcludedDomains;

View File

@ -139,14 +139,26 @@
<tbody class="js-twofas-auto-submit-excluded-domain-list"></tbody>
</table>
<a class="twofas-options-page-content-auto-submit-excluded-domain-list-exclude js-twofas-auto-submit-excluded-domain-add" href="#">
<span class="twofas-options-page-content-auto-submit-excluded-domain-list-exclude-icon">
<svg width="26" height="26" viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg">
<path id="Shape" d="M11.4919 1.42856H10.4919V2.42856V10.4898H2.43066H1.43066V11.4898V14.5102V15.5102H2.43066H10.4919V23.5714V24.5714H11.4919H14.5123H15.5123V23.5714V15.5102H23.5735H24.5735V14.5102V11.4898V10.4898H23.5735H15.5123V2.42856V1.42856H14.5123H11.4919Z" fill="white" stroke="white"/>
</svg>
</span>
<span data-i18n="optionsExcludeAnotherDomain" class="twofas-options-page-content-auto-submit-excluded-domain-list-exclude-text">Exclude another domain</span>
</a>
<div class="twofas-options-page-content-auto-submit-excluded-domain-list-buttons">
<a class="twofas-options-page-content-auto-submit-excluded-domain-list-exclude js-twofas-auto-submit-excluded-domain-add" href="#">
<span class="twofas-options-page-content-auto-submit-excluded-domain-list-exclude-icon">
<svg width="26" height="26" viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg">
<path id="Shape" d="M11.4919 1.42856H10.4919V2.42856V10.4898H2.43066H1.43066V11.4898V14.5102V15.5102H2.43066H10.4919V23.5714V24.5714H11.4919H14.5123H15.5123V23.5714V15.5102H23.5735H24.5735V14.5102V11.4898V10.4898H23.5735H15.5123V2.42856V1.42856H14.5123H11.4919Z" fill="white" stroke="white"/>
</svg>
</span>
<span data-i18n="optionsExcludeAnotherDomain" class="twofas-options-page-content-auto-submit-excluded-domain-list-exclude-text">Exclude domain</span>
</a>
<a class="twofas-options-page-content-auto-submit-excluded-domain-list-exclude import-default js-twofas-auto-submit-excluded-domain-import-default" href="#">
<span data-i18n="optionsExcludeImportDefault" class="twofas-options-page-content-auto-submit-excluded-domain-list-exclude-text">Import default list</span>
<span class="twofas-options-page-content-auto-submit-excluded-domain-list-exclude-icon">
<svg viewBox="0 0 19 26" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3.80577 25.8655H16.2891C18.8013 25.8655 20.0948 24.5506 20.0948 22.0287V11.3966C20.0948 9.76883 19.8853 9.02188 18.8655 7.9829L12.7101 1.7314C11.7309 0.730858 10.9167 0.5 9.45444 0.5H3.80577C1.30523 0.5 0 1.82445 0 4.34632V22.0287C0 24.5602 1.29562 25.8655 3.80577 25.8655ZM3.98905 23.5695C2.85795 23.5695 2.29592 22.9777 2.29592 21.886V4.48905C2.29592 3.40694 2.85795 2.79592 3.99866 2.79592H8.99414V9.22273C8.99414 10.8997 9.81257 11.7106 11.482 11.7106H17.7989V21.886C17.7989 22.9777 17.2369 23.5695 16.0983 23.5695H3.98905ZM11.6993 9.68586C11.2137 9.68586 11.0189 9.47937 11.0189 8.99586V3.11491L17.4799 9.68586H11.6993Z" fill="white"/>
<path d="M11.0646 13.9803C11.0646 13.4239 10.5996 13.0055 10.0474 13.0055C9.49521 13.0055 9.03021 13.4239 9.03021 13.9803V17.5867L9.11529 19.4124L8.21622 18.4677L7.31762 17.5456C7.14301 17.3509 6.87372 17.2339 6.62364 17.2339C6.09044 17.2339 5.7063 17.6117 5.7063 18.1269C5.7063 18.4238 5.81388 18.6399 6.03302 18.8314L9.27091 21.7977C9.5381 22.0414 9.76779 22.1509 10.0474 22.1509C10.327 22.1509 10.5567 22.0414 10.8239 21.7977L14.0618 18.8314C14.2809 18.6399 14.3885 18.4238 14.3885 18.1269C14.3885 17.6117 13.9969 17.2339 13.4733 17.2339C13.2136 17.2339 12.9476 17.3509 12.7772 17.5456L11.8807 18.4677L10.9795 19.4124L11.0646 17.5867V13.9803Z" fill="white"/>
</svg>
</span>
</a>
</div>
</div>
</div>

View File

@ -25,7 +25,7 @@ const TwoFasNotification = require('../notification');
const SDK = require('../sdk');
const extPageOnMessage = require('../partials/extPageOnMessage');
const { delay, storeLog, handleTargetBlank, hidePreloader, storageValidation } = require('../partials');
const { generateDevicesList, setLoggingToggle, setContextMenuToggle, setPushRadio, setPinInfo, setExtName, setExtNameUpdateForm, setModalsListeners, setAdvanced, setMenuLinks, setPinInfoBtns, setShortcutBox, setHamburger, setExtVersion, generateShortcutBox, generateShortcutLink, showIntegrityError, generateDomainsList } = require('./functions');
const { generateDevicesList, setLoggingToggle, setContextMenuToggle, setPushRadio, setPinInfo, setExtName, setExtNameUpdateForm, setModalsListeners, setAdvanced, setMenuLinks, setPinInfoBtns, setShortcutBox, setHamburger, setExtVersion, generateShortcutBox, generateShortcutLink, showIntegrityError, generateDomainsList, setImportDefaultExcludedDomains } = require('./functions');
const init = async storage => {
i18n();
@ -49,6 +49,7 @@ const init = async storage => {
return new SDK().getAllPairedDevices(storage.extensionID)
.then(generateDevicesList)
.then(() => generateDomainsList(storage.autoSubmitExcludedDomains))
.then(setImportDefaultExcludedDomains)
.then(setPinInfo)
.then(() => setExtName(storage.browserInfo.name))
.then(() => setExtNameUpdateForm(storage))

View File

@ -460,6 +460,14 @@
padding-bottom: 10px;
}
}
&[colspan="2"] {
@media all and (max-width: 660px) {
&::before {
content: '';
}
}
}
}
}
}
@ -533,6 +541,27 @@
}
}
&.import-default {
@media all and (max-width: 600px) {
flex-direction: row-reverse;
}
.twofas-options-page-content-auto-submit-excluded-domain-list-exclude-icon {
margin-left: 11px;
margin-right: 0;
@media all and (max-width: 600px) {
margin-left: 0;
margin-right: 11px;
}
svg {
height: 16px;
width: 16px;
}
}
}
&-icon {
align-items: center;
background-color: $theme-color;
@ -562,6 +591,21 @@
transition: color .2s ease-in-out;
}
}
&-buttons {
display: flex;
flex-direction: row;
gap: 0 20px;
justify-content: space-between;
width: 100%;
@media all and (max-width: 600px) {
align-items: flex-start;
flex-direction: column;
gap: 20px 0;
justify-content: flex-start;
}
}
}
&-advanced {

View File

@ -78,7 +78,8 @@ const selectors = {
autoSubmit: {
list: '.js-twofas-auto-submit-excluded-domain-list',
exclude: '.js-twofas-auto-submit-excluded-domain-exclude',
add: '.js-twofas-auto-submit-excluded-domain-add'
add: '.js-twofas-auto-submit-excluded-domain-add',
importDefault: '.js-twofas-auto-submit-excluded-domain-import-default'
},
menuLink: '.js-twofas-menu-link',
extVersion: 'span.twofas-ext-version',