Fix for token enter key on login screen, #3760

Ylian Saint-Hilaire committed Mar 14, 2022 at 17:36 UTC 71b3dacbdee40a898d09e3f432548aacf8603564
1 file changed +9 -5
views/login2.handlebars
+9 -5
@@ -185,7 +185,7 @@
185 <table style="width:100%">
186 <tr>
187 <td>
188 - <input id=tokenInput {{{autocomplete}}}="one-time-code" title="Token" style="box-sizing:border-box;width:280px;border:0;border-radius:4px;padding:8px;background-color:#FFF8CC" placeholder="Token" type=text maxlength=50 name=token onchange=checkToken(event) onpaste=resetCheckToken(event) onkeyup=checkToken(event) onkeydown=checkToken(event) /><br />
188 + <input id=tokenInput {{{autocomplete}}}="one-time-code" title="Token" style="box-sizing:border-box;width:280px;border:0;border-radius:4px;padding:8px;background-color:#FFF8CC" placeholder="Token" type=text maxlength=50 name=token onchange=checkToken(event) onpaste=checkToken(event) onkeyup=checkToken(event) onkeydown=checkToken(event) /><br />
189 <input id=hwtokenInput type=text name=hwtoken style="display:none" />
190 </td>
191 </tr>
@@ -864,18 +864,22 @@
864 return counts;
865 }
866
867 - function checkToken() {
867 + function checkToken(e) {
868 var t1 = Q('tokenInput').value;
869 var t2 = t1.split(' ').join('');
870 if (t1 != t2) { Q('tokenInput').value = t2; }
871 - QE('tokenOkButton', (Q('tokenInput').value.length == 6) || (Q('tokenInput').value.length == 8) || (Q('tokenInput').value.length == 44));
871 + var enabled = (Q('tokenInput').value.length == 6) || (Q('tokenInput').value.length == 8) || (Q('tokenInput').value.length == 44);
872 + QE('tokenOkButton', enabled);
873 + if (enabled && (e != null) && (e.keyCode == 13)) { submitButtonClicked('tokenpanelform'); }
874 }
875
874 - function resetCheckToken() {
876 + function resetCheckToken(e) {
877 var t1 = Q('resetTokenInput').value;
878 var t2 = t1.split(' ').join('');
879 if (t1 != t2) { Q('resetTokenInput').value = t2; }
878 - QE('resetTokenOkButton', (Q('resetTokenInput').value.length == 6) || (Q('resetTokenInput').value.length == 8) || (Q('resetTokenInput').value.length == 44));
880 + var enabled = (Q('resetTokenInput').value.length == 6) || (Q('resetTokenInput').value.length == 8) || (Q('resetTokenInput').value.length == 44);
881 + QE('resetTokenOkButton', enabled);
882 + if (enabled && (e != null) && (e.keyCode == 13)) { submitButtonClicked('resettokenpanelform'); }
883 }
884
885 function changeEmailAddress() {