mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Added CAPTCHA option when creating new accounts on login screen.
This commit is contained in:
parent
4382899468
commit
04fb1f2bf0
8 changed files with 102 additions and 22 deletions
|
@ -122,6 +122,14 @@
|
|||
<td id="nuToken" align=right>Creation Token:</td>
|
||||
<td><input id=anewaccountpass type=password name=anewaccountpass {{{autocomplete}}}=off maxlength=256 onkeydown=haltReturn(event) onchange=validateCreate(6,event) onkeyup=validateCreate(6,event) /></td>
|
||||
</tr>
|
||||
<tr id=newAccountCaptchaImg title="CAPTCHA image">
|
||||
<td></td>
|
||||
<td colspan=2><img src="{{{newAccountCaptchaImage}}}" loading="lazy" /></td>
|
||||
</tr>
|
||||
<tr id=newAccountCaptcha title="Security check">
|
||||
<td id="nuCaptcha" align=right>Security Check:</td>
|
||||
<td><input id=anewaccountcaptcha type=text name=anewaccountcaptcha {{{autocomplete}}}=off maxlength=256 onkeydown=haltReturn(event) onchange=validateCreate(7,event) onkeyup=validateCreate(7,event) /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2>
|
||||
<div style=float:right><input id=createButton type=submit value="Create Account" disabled="disabled" /></div>
|
||||
|
@ -131,6 +139,7 @@
|
|||
</table>
|
||||
<hr /><a onclick="return xgo(1,event);" href="#" style=cursor:pointer>Back to login</a>
|
||||
<input id=createformargs name="urlargs" type="hidden" value="" />
|
||||
<input id=createformcaptcha name="captchaargs" type="hidden" value="{{{newAccountCaptcha}}}" />
|
||||
</form>
|
||||
</div>
|
||||
<div id=resetpanel style="display:none">
|
||||
|
@ -311,6 +320,7 @@
|
|||
var loginMode = '{{{loginmode}}}';
|
||||
var newAccount = '{{{newAccount}}}';
|
||||
var newAccountPass = parseInt('{{{newAccountPass}}}');
|
||||
var newAccountCaptcha = '{{{newAccountCaptcha}}}';
|
||||
var emailCheck = '{{{emailcheck}}}';
|
||||
var passRequirements = '{{{passRequirements}}}';
|
||||
var hardwareKeyChallenge = decodeURIComponent('{{{hkey}}}');
|
||||
|
@ -335,7 +345,7 @@
|
|||
var i;
|
||||
var messageid = parseInt('{{{messageid}}}');
|
||||
var okmessages = ['', "If valid, reset mail sent.", "Email sent.", "Email verification required, check your mailbox and click the confirmation link.", "SMS sent."];
|
||||
var failmessages = ["Unable to create account.", "Account limit reached.", "Existing account with this email address.", "Invalid account creation token.", "Username already exists.", "Password rejected, use a different one.", "Invalid email.", "Account not found.", "Invalid token, try again.", "Unable to sent email.", "Account locked.", "Access denied.", "Login failed, check username and password.", "Password change requested.", "IP address blocked, try again later.", "Server under maintenance."];
|
||||
var failmessages = ["Unable to create account.", "Account limit reached.", "Existing account with this email address.", "Invalid account creation token.", "Username already exists.", "Password rejected, use a different one.", "Invalid email.", "Account not found.", "Invalid token, try again.", "Unable to sent email.", "Account locked.", "Access denied.", "Login failed, check username and password.", "Password change requested.", "IP address blocked, try again later.", "Server under maintenance.", "Unable to send device notification.", "Invalid security check."];
|
||||
if (messageid > 0) {
|
||||
var msg = '';
|
||||
if ((messageid < 100) && (messageid < okmessages.length)) { msg = okmessages[messageid]; }
|
||||
|
@ -433,6 +443,8 @@
|
|||
QV('newAccountDiv', (newAccount === '1') || (newAccount === 'true')); // If new accounts are not allowed, don't display the new account link.
|
||||
if ((passhint != null) && (passhint.length > 0)) { QV('showPassHintLink', true); }
|
||||
QV('newAccountPass', (newAccountPass == 1));
|
||||
QV('newAccountCaptcha', (newAccountCaptcha != ''));
|
||||
QV('newAccountCaptchaImg', (newAccountCaptcha != ''));
|
||||
QV('resetAccountDiv', (emailCheck == 'true'));
|
||||
QV('hrAccountDiv', (emailCheck == 'true') || (newAccountPass == 1));
|
||||
|
||||
|
@ -627,6 +639,7 @@
|
|||
var pass1ok = (Q('apassword1').value.length > 0);
|
||||
var pass2ok = (Q('apassword2').value.length > 0) && (Q('apassword2').value == Q('apassword1').value);
|
||||
var newAccOk = (newAccountPass == 0) || (Q('anewaccountpass').value.length > 0);
|
||||
var newCaptchaOk = (newAccountCaptcha == '') || (Q('anewaccountcaptcha').value.length > 0);
|
||||
var ok = (userok && emailok && pass1ok && pass2ok && newAccOk);
|
||||
|
||||
// Color the fields
|
||||
|
@ -635,6 +648,7 @@
|
|||
QS('nuPass1').color = pass1ok ? 'black' : '#7b241c';
|
||||
QS('nuPass2').color = pass2ok ? 'black' : '#7b241c';
|
||||
QS('nuToken').color = newAccOk ? 'black' : '#7b241c';
|
||||
QS('nuCaptcha').color = newCaptchaOk ? 'black' : '#7b241c';
|
||||
|
||||
if (Q('apassword1').value == '') {
|
||||
QH('passWarning', '');
|
||||
|
@ -663,13 +677,13 @@
|
|||
}
|
||||
}
|
||||
if ((e != null) && (e.keyCode == 13)) {
|
||||
|
||||
if ((box == 1) && userok) { Q('aemail').focus(); }
|
||||
if ((box == 2) && emailok) { Q('apassword1').focus(); }
|
||||
if ((box == 3) && pass1ok) { Q('apassword2').focus(); }
|
||||
if ((box == 4) && pass2ok) { if (passRequirements.hint === true) { Q('apasswordhint').focus(); } else { box = 5; } }
|
||||
if (box == 5) { if (newAccountPass == 1) { Q('anewaccountpass').focus(); } else { box = 6; } }
|
||||
if (box == 6) { Q('createButton').click(); }
|
||||
if (box == 6) { if (newAccountCaptcha != '') { Q('anewaccountcaptcha').focus(); } else { box = 7; } }
|
||||
if (box == 7) { Q('createButton').click(); }
|
||||
}
|
||||
if (e != null) { haltEvent(e); }
|
||||
QE('createButton', ok);
|
||||
|
|
|
@ -144,6 +144,14 @@
|
|||
<td id="nuToken" align=right>Creation Token:</td>
|
||||
<td><input id=anewaccountpass type=password name=anewaccountpass {{{autocomplete}}}=off maxlength=256 onkeydown=haltReturn(event) onchange=validateCreate(6,event) onkeyup=validateCreate(6,event) /></td>
|
||||
</tr>
|
||||
<tr id=newAccountCaptchaImg title="CAPTCHA image">
|
||||
<td></td>
|
||||
<td colspan=2><img src="{{{newAccountCaptchaImage}}}" loading="lazy" /></td>
|
||||
</tr>
|
||||
<tr id=newAccountCaptcha title="Security check">
|
||||
<td id="nuCaptcha" align=right>Security Check:</td>
|
||||
<td><input id=anewaccountcaptcha type=text name=anewaccountcaptcha {{{autocomplete}}}=off maxlength=256 onkeydown=haltReturn(event) onchange=validateCreate(7,event) onkeyup=validateCreate(7,event) /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2>
|
||||
<div style=float:right><input id=createButton type="button" onclick="submitButtonClicked('createpanelform')" value="Create Account" disabled="disabled" /></div>
|
||||
|
@ -153,6 +161,7 @@
|
|||
</table>
|
||||
<hr /><a onclick="return xgo(1,event);" href="#" style=cursor:pointer>Back to login</a>
|
||||
<input id=createformargs name="urlargs" type="hidden" value="" />
|
||||
<input id=createformcaptcha name="captchaargs" type="hidden" value="{{{newAccountCaptcha}}}" />
|
||||
</form>
|
||||
</div>
|
||||
<div id=resetpanel style="display:none">
|
||||
|
@ -368,6 +377,7 @@
|
|||
var loginMode = '{{{loginmode}}}';
|
||||
var newAccount = '{{{newAccount}}}';
|
||||
var newAccountPass = parseInt('{{{newAccountPass}}}');
|
||||
var newAccountCaptcha = '{{{newAccountCaptcha}}}';
|
||||
var emailCheck = '{{{emailcheck}}}';
|
||||
var passRequirements = '{{{passRequirements}}}';
|
||||
var hardwareKeyChallenge = decodeURIComponent('{{{hkey}}}');
|
||||
|
@ -405,7 +415,7 @@
|
|||
var i;
|
||||
var messageid = parseInt('{{{messageid}}}');
|
||||
var okmessages = ['', "If valid, reset mail sent.", "Email sent.", "Email verification required, check your mailbox and click the confirmation link.", "SMS sent.", "Sending notification..."];
|
||||
var failmessages = ["Unable to create account.", "Account limit reached.", "Existing account with this email address.", "Invalid account creation token.", "Username already exists.", "Password rejected, use a different one.", "Invalid email.", "Account not found.", "Invalid token, try again.", "Unable to sent email.", "Account locked.", "Access denied.", "Login failed, check username and password.", "Password change requested.", "IP address blocked, try again later.", "Server under maintenance.", "Unable to send device notification."];
|
||||
var failmessages = ["Unable to create account.", "Account limit reached.", "Existing account with this email address.", "Invalid account creation token.", "Username already exists.", "Password rejected, use a different one.", "Invalid email.", "Account not found.", "Invalid token, try again.", "Unable to sent email.", "Account locked.", "Access denied.", "Login failed, check username and password.", "Password change requested.", "IP address blocked, try again later.", "Server under maintenance.", "Unable to send device notification.", "Invalid security check."];
|
||||
if (messageid > 0) {
|
||||
var msg = '';
|
||||
if ((messageid < 100) && (messageid < okmessages.length)) { msg = okmessages[messageid]; }
|
||||
|
@ -487,6 +497,8 @@
|
|||
QV('newAccountDiv', (newAccount === '1') || (newAccount === 'true')); // If new accounts are not allowed, don't display the new account link.
|
||||
if ((passhint != null) && (passhint.length > 0)) { QV('showPassHintLink', true); }
|
||||
QV('newAccountPass', (newAccountPass == 1));
|
||||
QV('newAccountCaptcha', (newAccountCaptcha != ''));
|
||||
QV('newAccountCaptchaImg', (newAccountCaptcha != ''));
|
||||
QV('resetAccountDiv', (emailCheck == 'true'));
|
||||
QV('hrAccountDiv', (emailCheck == 'true') || (newAccountPass == 1));
|
||||
|
||||
|
@ -712,6 +724,7 @@
|
|||
var pass1ok = (Q('apassword1').value.length > 0);
|
||||
var pass2ok = (Q('apassword2').value.length > 0) && (Q('apassword2').value == Q('apassword1').value);
|
||||
var newAccOk = (newAccountPass == 0) || (Q('anewaccountpass').value.length > 0);
|
||||
var newCaptchaOk = (newAccountCaptcha == '') || (Q('anewaccountcaptcha').value.length > 0);
|
||||
var ok = (userok && emailok && pass1ok && pass2ok && newAccOk);
|
||||
|
||||
// Color the fields
|
||||
|
@ -720,6 +733,7 @@
|
|||
QS('nuPass1').color = pass1ok ? 'black' : '#7b241c';
|
||||
QS('nuPass2').color = pass2ok ? 'black' : '#7b241c';
|
||||
QS('nuToken').color = newAccOk ? 'black' : '#7b241c';
|
||||
QS('nuCaptcha').color = newCaptchaOk ? 'black' : '#7b241c';
|
||||
|
||||
if (Q('apassword1').value == '') {
|
||||
QH('passWarning', '');
|
||||
|
@ -748,13 +762,13 @@
|
|||
}
|
||||
}
|
||||
if ((e != null) && (e.keyCode == 13)) {
|
||||
|
||||
if ((box == 1) && userok) { Q('aemail').focus(); }
|
||||
if ((box == 2) && emailok) { Q('apassword1').focus(); }
|
||||
if ((box == 3) && pass1ok) { Q('apassword2').focus(); }
|
||||
if ((box == 4) && pass2ok) { if (passRequirements.hint === true) { Q('apasswordhint').focus(); } else { box = 5; } }
|
||||
if (box == 5) { if (newAccountPass == 1) { Q('anewaccountpass').focus(); } else { box = 6; } }
|
||||
if (box == 6) { Q('createButton').click(); }
|
||||
if (box == 6) { if (newAccountCaptcha != '') { Q('anewaccountcaptcha').focus(); } else { box = 7; } }
|
||||
if (box == 7) { Q('createButton').click(); }
|
||||
}
|
||||
if (e != null) { haltEvent(e); }
|
||||
QE('createButton', ok);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue