mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Improved login screen, Mesh server directory handling
This commit is contained in:
parent
8e835fcbb2
commit
789e48a5c1
8 changed files with 116 additions and 57 deletions
|
@ -73,7 +73,7 @@
|
|||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div id=createpanel style="display:none">
|
||||
<div id=createpanel style="position:relative;display:none">
|
||||
<div style="background-color: #979797;border-radius:16px;width:260px;padding:16px;text-align:center;clear:both">
|
||||
<form action=createaccount method=post>
|
||||
<div id=message2>
|
||||
|
@ -82,6 +82,7 @@
|
|||
<div>
|
||||
<b>Account Creation</b>
|
||||
</div>
|
||||
<div id="passwordPolicyCallout" style="left:-5px;top:10px;width:100px;position:absolute;background-color:#FFC;border-radius:5px;padding:5px;box-shadow:0px 0px 15px #666;font-size:10px"></div>
|
||||
<table>
|
||||
<tr>
|
||||
<td align=right width=100>Username:</td>
|
||||
|
@ -173,7 +174,7 @@
|
|||
<tr>
|
||||
<td align=right width=100>Login token:</td>
|
||||
<td>
|
||||
<input id=resetTokenInput type=text name=token maxlength=50 onchange=resetCheckToken(event) onkeyup=resetCheckToken(event) onkeydown=resetCheckToken(event) />
|
||||
<input id=resetTokenInput type=text name=token maxlength=50 onchange=resetCheckToken(event) onpaste=resetCheckToken(event) onkeyup=resetCheckToken(event) onkeydown=resetCheckToken(event) />
|
||||
<input id=resetHwtokenInput type=text name=hwtoken style="display:none" />
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -318,6 +319,7 @@
|
|||
if ((newAccountPass == 1) && (Q('anewaccountpass').value.length == 0)) { ok = false; }
|
||||
if (Q('apassword1').value == '') {
|
||||
QH('passWarning', '');
|
||||
QV('passwordPolicyCallout', false);
|
||||
} else {
|
||||
if (passRequirements == null || passRequirements == '') {
|
||||
// No password requirements, display password strength
|
||||
|
@ -333,8 +335,11 @@
|
|||
//QS('nuPass1').color = '#7b241c';
|
||||
//QS('nuPass2').color = '#7b241c';
|
||||
QH('passWarning', '<span style=color:red><b>Password Policy</b><span>'); // TODO: Display problem hint
|
||||
QV('passwordPolicyCallout', true);
|
||||
QH('passwordPolicyCallout', passwordPolicyText(Q('apassword1').value));
|
||||
} else {
|
||||
QH('passWarning', '');
|
||||
QV('passwordPolicyCallout', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -360,6 +365,19 @@
|
|||
if (e != null) { haltEvent(e); }
|
||||
}
|
||||
|
||||
function passwordPolicyText(pass) {
|
||||
var policy = '<div style=text-align:left>';
|
||||
var counts = strCount(pass);
|
||||
if (passRequirements.min && ((pass == null) || (pass.length < passRequirements.min))) { policy += 'Minimum length of ' + passRequirements.min + '<br />'; }
|
||||
if (passRequirements.max && ((pass == null) || (pass.length > passRequirements.max))) { policy += 'Maximum length of ' + passRequirements.max + '<br />'; }
|
||||
if (passRequirements.upper && ((pass == null) || (counts.upper < passRequirements.upper))) { policy += '' + passRequirements.upper + ' upper case<br />'; }
|
||||
if (passRequirements.lower && ((pass == null) || (counts.lower < passRequirements.lower))) { policy += '' + passRequirements.lower + ' lower case<br />'; }
|
||||
if (passRequirements.numeric && ((pass == null) || (counts.numeric < passRequirements.numeric))) { policy += '' + passRequirements.numeric + ' numeric<br />'; }
|
||||
if (passRequirements.nonalpha && ((pass == null) || (counts.nonalpha < passRequirements.nonalpha))) { policy += passRequirements.nonalpha + ' non-alphanumeric<br />'; }
|
||||
policy += '</div>';
|
||||
return policy;
|
||||
}
|
||||
|
||||
// Return a password strength score
|
||||
function checkPasswordStrength(password) {
|
||||
var r = 0, letters = {}, varCount = 0, variations = { digits: /\d/.test(password), lower: /[a-z]/.test(password), upper: /[A-Z]/.test(password), nonWords: /\W/.test(password) }
|
||||
|
@ -374,20 +392,26 @@
|
|||
if ((requirements == null) || (requirements == '') || (typeof requirements != 'object')) return true;
|
||||
if (requirements.min) { if (password.length < requirements.min) return false; }
|
||||
if (requirements.max) { if (password.length > requirements.max) return false; }
|
||||
var num = 0, lower = 0, upper = 0, nonalpha = 0;
|
||||
for (var i = 0; i < password.length; i++) {
|
||||
if (/\d/.test(password[i])) { num++; }
|
||||
if (/[a-z]/.test(password[i])) { lower++; }
|
||||
if (/[A-Z]/.test(password[i])) { upper++; }
|
||||
if (/\W/.test(password[i])) { nonalpha++; }
|
||||
}
|
||||
if (requirements.num && (num < requirements.num)) return false;
|
||||
if (requirements.lower && (lower < requirements.lower)) return false;
|
||||
if (requirements.upper && (upper < requirements.upper)) return false;
|
||||
if (requirements.nonalpha && (nonalpha < requirements.nonalpha)) return false;
|
||||
var counts = strCount(password);
|
||||
if (requirements.numeric && (counts.numeric < requirements.numeric)) return false;
|
||||
if (requirements.lower && (counts.lower < requirements.lower)) return false;
|
||||
if (requirements.upper && (counts.upper < requirements.upper)) return false;
|
||||
if (requirements.nonalpha && (counts.nonalpha < requirements.nonalpha)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function strCount(password) {
|
||||
var counts = { numeric: 0, lower: 0, upper: 0, nonalpha: 0 };
|
||||
if (typeof password != 'string') return counts;
|
||||
for (var i = 0; i < password.length; i++) {
|
||||
if (/\d/.test(password[i])) { counts.numeric++; }
|
||||
if (/[a-z]/.test(password[i])) { counts.lower++; }
|
||||
if (/[A-Z]/.test(password[i])) { counts.upper++; }
|
||||
if (/\W/.test(password[i])) { counts.nonalpha++; }
|
||||
}
|
||||
return counts;
|
||||
}
|
||||
|
||||
function checkToken() {
|
||||
var t1 = Q('tokenInput').value;
|
||||
var t2 = t1.split(' ').join('');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue