fix `enableOTP` handling to match docs: prioritize store, then extension config
This commit is contained in:
parent
55889b8f61
commit
70113ee29e
|
@ -565,12 +565,12 @@ async function getFullSettings() {
|
|||
* Get most relevant setting value
|
||||
*
|
||||
* @param string key Setting key
|
||||
* @param object login Login object
|
||||
* @param object login Login object (or null)
|
||||
* @param object settings Settings object
|
||||
* @return object Setting value
|
||||
*/
|
||||
function getSetting(key, login, settings) {
|
||||
if (typeof login.settings[key] !== "undefined") {
|
||||
if (login !== null && typeof login.settings[key] !== "undefined") {
|
||||
return login.settings[key];
|
||||
}
|
||||
if (typeof settings.stores[login.store.id].settings[key] !== "undefined") {
|
||||
|
@ -743,7 +743,7 @@ async function handleMessage(settings, message, sendResponse) {
|
|||
}
|
||||
break;
|
||||
case "copyOTP":
|
||||
if (settings.enableOTP) {
|
||||
if (getSetting("enableOTP", null, settings)) {
|
||||
try {
|
||||
if (!message.login.fields.otp) {
|
||||
throw new Exception("No OTP seed available");
|
||||
|
@ -815,7 +815,7 @@ async function handleMessage(settings, message, sendResponse) {
|
|||
|
||||
// copy OTP token after fill
|
||||
if (
|
||||
settings.enableOTP &&
|
||||
getSetting("enableOTP", null, settings) &&
|
||||
typeof message.login !== "undefined" &&
|
||||
message.login.fields.hasOwnProperty("otp")
|
||||
) {
|
||||
|
@ -982,7 +982,7 @@ async function parseFields(settings, login) {
|
|||
}
|
||||
|
||||
// preprocess otp
|
||||
if (settings.enableOTP && login.fields.hasOwnProperty("otp")) {
|
||||
if (getSetting("enableOTP", null, settings) && login.fields.hasOwnProperty("otp")) {
|
||||
if (login.fields.otp.match(/^otpauth:\/\/.+/i)) {
|
||||
// attempt to parse otp data as URI
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue