Fixed using timed OTP when backup codes are not allowed (#4268)

Ylian Saint-Hilaire committed Jul 14, 2022 at 13:55 UTC 138fc507c81f68dea1092743577145078552d102
2 files changed +6 -18
meshuser.js
-6
@@ -3330,9 +3330,6 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
3330 // Do not allow this command if 2FA's are locked
3331 if ((domain.passwordrequirements) && (domain.passwordrequirements.lock2factor == true)) { ws.send(JSON.stringify({ action: 'otpauth-request', err: 1 })); return; }
3332
3333 - // Do not allow this command if backup codes are not allowed
3334 - if ((domain.passwordrequirements) && (domain.passwordrequirements.backupcode2factor == false)) { ws.send(JSON.stringify({ action: 'otpauth-request', err: 2 })); return; }
3335 -
3333 // Do not allow this command when logged in using a login token
3334 if (req.session.loginToken != null) { ws.send(JSON.stringify({ action: 'otpauth-request', err: 3 })); return; }
3335
@@ -3361,9 +3358,6 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
3358 // Do not allow this command if 2FA's are locked
3359 if ((domain.passwordrequirements) && (domain.passwordrequirements.lock2factor == true)) return;
3360
3364 - // Do not allow this command if backup codes are not allowed
3365 - if ((domain.passwordrequirements) && (domain.passwordrequirements.backupcode2factor == false)) return;
3366 -
3361 // Do not allow this command when logged in using a login token
3362 if (req.session.loginToken != null) break;
3363
views/default.handlebars
+6 -12
@@ -2931,11 +2931,9 @@
2931 QS('dialog').bottom = '80px';
2932 QS('dialog').top = QS('dialog').left = QS('dialog').right = '100px';
2933 if (d4EditEncodingVal == 1) {
2934 - // UTF8 Encoding
2935 - Q('d4editorarea').value = decode_utf8(atob(message.data));
2934 + Q('d4editorarea').value = decode_utf8(atob(message.data)); // UTF8 Encoding
2935 } else {
2937 - // RAW Encoding
2938 - Q('d4editorarea').value = atob(message.data);
2936 + Q('d4editorarea').value = atob(message.data); // RAW Encoding
2937 }
2938 break;
2939 }
@@ -10717,11 +10715,9 @@
10715 QS('dialog').bottom = '80px';
10716 QS('dialog').top = QS('dialog').left = QS('dialog').right = '100px';
10717 if (d4EditEncodingVal == 1) {
10720 - // UTF8 Encoding
10721 - Q('d4editorarea').value = decode_utf8(gdownloadFile.data);
10718 + Q('d4editorarea').value = decode_utf8(gdownloadFile.data); // UTF8 Encoding
10719 } else {
10723 - // RAW Encoding
10724 - Q('d4editorarea').value = gdownloadFile.data;
10720 + Q('d4editorarea').value = gdownloadFile.data; // RAW Encoding
10721 }
10722 gdownloadFile = null;
10723 } else {
@@ -10767,11 +10763,9 @@
10763 function p13editSaveBack(b, tag) {
10764 var data;
10765 if (d4EditEncodingVal == 1) {
10770 - // UTF8 encoding
10771 - data = new TextEncoder().encode(Q('d4editorarea').value);
10766 + data = new TextEncoder().encode(Q('d4editorarea').value); // UTF8 encoding
10767 } else {
10773 - // RAW encoding
10774 - data = new TextEncoder().encode(decode_utf8(Q('d4editorarea').value));
10768 + data = new TextEncoder().encode(decode_utf8(Q('d4editorarea').value)); // RAW encoding
10769 }
10770 p13uploadFileContinue(1, [{ name: tag, size: data.byteLength, type: 'text/plain', xdata: data }]);
10771 }