mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-25 20:51:23 +03:00
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 <simonsmith5521@gmail.com>
This commit is contained in:
parent
ac27034542
commit
63930c4b33
@ -63,15 +63,15 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td id=loginusername align=right width=100>Username:</td>
|
<td id=loginusername align=right width=100>Username:</td>
|
||||||
<td><input id=username type=text autocomplete="username" maxlength=64 name=username onchange=validateLogin(1) onkeyup=validateLogin(1,event) /></td>
|
<td><input id=username type=text autocomplete="username" maxlength=64 name=username required /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align=right>Password:</td>
|
<td align=right>Password:</td>
|
||||||
<td><input id=password type=password autocomplete="current-password" maxlength=256 name=password autocomplete=off onchange=validateLogin(2) onkeyup=validateLogin(2,event) /></td>
|
<td><input id=password type=password autocomplete="current-password" maxlength=256 name=password autocomplete=off required /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><div id=showPassHintLink style=display:none><a onclick=showPassHint() style="cursor:pointer">Show Hint</a></div></td>
|
<td><div id=showPassHintLink style=display:none><a onclick=showPassHint() style="cursor:pointer">Show Hint</a></div></td>
|
||||||
<td align=right><input id=loginButton type=submit value="Log In" disabled="disabled" /></td>
|
<td align=right><input id=loginButton type=submit value="Log In" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div id="hrAccountDiv" style="display:none"><hr /></div>
|
<div id="hrAccountDiv" style="display:none"><hr /></div>
|
||||||
@ -422,7 +422,6 @@
|
|||||||
|
|
||||||
window.onresize = center;
|
window.onresize = center;
|
||||||
center();
|
center();
|
||||||
validateLogin();
|
|
||||||
validateCreate();
|
validateCreate();
|
||||||
if (loginMode.length != 0) { go(parseInt(loginMode)); } else { go(1); }
|
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.
|
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) {
|
function validateCreate(box,e) {
|
||||||
setDialogMode(0);
|
setDialogMode(0);
|
||||||
var ok = false;
|
var ok = false;
|
||||||
|
@ -55,15 +55,15 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td id=loginusername align=right width=100>Username:</td>
|
<td id=loginusername align=right width=100>Username:</td>
|
||||||
<td><input id=username {{{autocomplete}}}="username" type=text maxlength=64 name=username onchange=validateLogin(1) onkeyup=validateLogin(1,event) /></td>
|
<td><input id=username {{{autocomplete}}}="username" type=text maxlength=64 name=username required /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align=right>Password:</td>
|
<td align=right>Password:</td>
|
||||||
<td><input id=password {{{autocomplete}}}="current-password" type=password maxlength=256 name=password onchange=validateLogin(2) onkeyup=validateLogin(2,event) /></td>
|
<td><input id=password {{{autocomplete}}}="current-password" type=password maxlength=256 name=password required /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><div id=showPassHintLink style=display:none><a onclick="return showPassHint(event);" href="#" style="cursor:pointer">Show Hint</a></div></td>
|
<td><div id=showPassHintLink style=display:none><a onclick="return showPassHint(event);" href="#" style="cursor:pointer">Show Hint</a></div></td>
|
||||||
<td align=right><input id=loginButton type=submit value="Log In" disabled="disabled" /></td>
|
<td align=right><input id=loginButton type=submit value="Log In" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div id="hrAccountDiv" style="display:none"><hr /></div>
|
<div id="hrAccountDiv" style="display:none"><hr /></div>
|
||||||
@ -456,7 +456,6 @@
|
|||||||
window.onresize = center;
|
window.onresize = center;
|
||||||
center();
|
center();
|
||||||
|
|
||||||
validateLogin();
|
|
||||||
validateCreate();
|
validateCreate();
|
||||||
if (loginMode.length != 0) { go(parseInt(loginMode)); } else { go(1); }
|
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.
|
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) {
|
function validateCreate(box, e) {
|
||||||
setDialogMode(0);
|
setDialogMode(0);
|
||||||
var userok = false;
|
var userok = false;
|
||||||
|
@ -69,12 +69,12 @@
|
|||||||
<table style="width:100%">
|
<table style="width:100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input id=username title="Username" style="box-sizing:border-box;width:280px;border:0;border-radius:4px;padding:8px;background-color:#FFF8CC" {{{autocomplete}}}="username" placeholder="Username" type=text maxlength=64 name=username onchange=validateLogin(1) onkeyup=validateLogin(1,event) />
|
<input id=username title="Username" style="box-sizing:border-box;width:280px;border:0;border-radius:4px;padding:8px;background-color:#FFF8CC" {{{autocomplete}}}="username" placeholder="Username" type=text maxlength=64 name=username required />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input id=password title="Password" style="box-sizing:border-box;width:280px;border:0;border-radius:4px;padding:8px;background-color:#FFF8CC" {{{autocomplete}}}="current-password" placeholder="Password" type=password maxlength=256 name=password onchange=validateLogin(2) onkeyup=validateLogin(2,event) />
|
<input id=password title="Password" style="box-sizing:border-box;width:280px;border:0;border-radius:4px;padding:8px;background-color:#FFF8CC" {{{autocomplete}}}="current-password" placeholder="Password" type=password maxlength=256 name=password required />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -84,7 +84,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input id=loginButton style="box-sizing:border-box;width:280px;border:0;border-radius:4px;padding:6px" onclick="submitButtonClicked('loginpanelform')" type=button value="Log In" disabled="disabled" />
|
<input id=loginButton style="box-sizing:border-box;width:280px;border:0;border-radius:4px;padding:6px" onclick="submitButtonClicked('loginpanelform')" type=button value="Log In" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr id="topLanguageSelectRow" style="display:none"><td id="topLanguageSelect"></td></tr>
|
<tr id="topLanguageSelectRow" style="display:none"><td id="topLanguageSelect"></td></tr>
|
||||||
@ -529,7 +529,6 @@
|
|||||||
if (authStrategies.indexOf('saml') >= 0) { QV('auth-saml', true); }
|
if (authStrategies.indexOf('saml') >= 0) { QV('auth-saml', true); }
|
||||||
}
|
}
|
||||||
|
|
||||||
validateLogin();
|
|
||||||
validateCreate();
|
validateCreate();
|
||||||
if (loginMode.length != 0) { go(parseInt(loginMode)); } else { go(1); }
|
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.
|
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(); }
|
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) {
|
function validateCreate(box, e) {
|
||||||
setDialogMode(0);
|
setDialogMode(0);
|
||||||
var userok = false;
|
var userok = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user