From 63930c4b3390784c87303c5d726bf4ae2f20dafc Mon Sep 17 00:00:00 2001 From: trmdi Date: Sat, 19 Oct 2024 22:47:33 +0700 Subject: [PATCH] Use built-in login validation (#6434) * Use built-in login validation * use button instead of submit to avoid duplicate submits --------- Co-authored-by: Simon Smith --- views/login-mobile.handlebars | 19 ++++--------------- views/login.handlebars | 19 ++++--------------- views/login2.handlebars | 22 ++++------------------ 3 files changed, 12 insertions(+), 48 deletions(-) diff --git a/views/login-mobile.handlebars b/views/login-mobile.handlebars index 30940bae..24f80c62 100644 --- a/views/login-mobile.handlebars +++ b/views/login-mobile.handlebars @@ -63,15 +63,15 @@ - + - + - +
Username:
Password:
@@ -422,7 +422,6 @@ window.onresize = center; center(); - validateLogin(); validateCreate(); if (loginMode.length != 0) { go(parseInt(loginMode)); } else { go(1); } QV('newAccountDiv', (newAccount === '1') || (newAccount === 'true')); // If new accounts are not allowed, don't display the new account link. @@ -573,16 +572,6 @@ } } - function validateLogin(box, e) { - setTimeout(function(){ - var ok = ((Q('username').value.length > 0) && (Q('username').value.indexOf(' ') == -1) && (Q('password').value.length > 0)); - QE('loginButton', ok); - setDialogMode(0); - if ((e != null) && (e.keyCode == 13)) { if (box == 1) { Q('password').focus(); } else if (box == 2) { Q('loginButton').click(); } } - if (e != null) { haltEvent(e); } - }, 100); - } - function validateCreate(box,e) { setDialogMode(0); var ok = false; @@ -818,4 +807,4 @@ - \ No newline at end of file + diff --git a/views/login.handlebars b/views/login.handlebars index 0ae79676..edbda542 100644 --- a/views/login.handlebars +++ b/views/login.handlebars @@ -55,15 +55,15 @@ - + - + - +
Username:
Password:
@@ -456,7 +456,6 @@ window.onresize = center; center(); - validateLogin(); validateCreate(); if (loginMode.length != 0) { go(parseInt(loginMode)); } else { go(1); } QV('newAccountDiv', (newAccount === '1') || (newAccount === 'true')); // If new accounts are not allowed, don't display the new account link. @@ -661,16 +660,6 @@ } } - function validateLogin(box, e) { - setTimeout(function(){ - var ok = ((Q('username').value.length > 0) && (Q('username').value.indexOf(' ') == -1) && (Q('password').value.length > 0)); - QE('loginButton', ok); - setDialogMode(0); - if ((e != null) && (e.keyCode == 13)) { if ((box == 1) && (Q('username').value != '')) { Q('password').focus(); } else if ((box == 2) && (Q('password').value != '')) { Q('loginButton').click(); } } - if (e != null) { haltEvent(e); } - }, 100); - } - function validateCreate(box, e) { setDialogMode(0); var userok = false; @@ -971,4 +960,4 @@ - \ No newline at end of file + diff --git a/views/login2.handlebars b/views/login2.handlebars index bbd78a55..8c6bdc32 100644 --- a/views/login2.handlebars +++ b/views/login2.handlebars @@ -69,12 +69,12 @@ @@ -84,7 +84,7 @@ @@ -529,7 +529,6 @@ if (authStrategies.indexOf('saml') >= 0) { QV('auth-saml', true); } } - validateLogin(); validateCreate(); if (loginMode.length != 0) { go(parseInt(loginMode)); } else { go(1); } QV('newAccountDiv', (newAccount === '1') || (newAccount === 'true')); // If new accounts are not allowed, don't display the new account link. @@ -772,19 +771,6 @@ if (!formSubmitted) { formSubmitted = true; document.getElementById(v).submit(); } } - function validateLogin(box, e) { - setTimeout(function(){ - var ok = ((Q('username').value.length > 0) && (Q('username').value.indexOf(' ') == -1) && (Q('password').value.length > 0)); - QE('loginButton', ok); - setDialogMode(0); - if ((e != null) && (e.keyCode == 13)) { - if ((box == 1) && (Q('username').value != '')) { Q('password').focus(); } - else if ((box == 2) && (Q('password').value != '')) { Q('loginButton').click(); } - } - if (e != null) { haltEvent(e); } - }, 100); - } - function validateCreate(box, e) { setDialogMode(0); var userok = false; @@ -1041,4 +1027,4 @@ - \ No newline at end of file +
- +
- +
- +