'); // This is also a link to the password policy
+ QV('passwordPolicyCallout', true);
+ QH('passwordPolicyCallout', passwordPolicyText(Q('apassword1').value));
} else {
QH('passWarning', '');
+ QV('passwordPolicyCallout', false);
}
}
}
@@ -447,16 +452,21 @@
QE('createButton', ok);
}
- function showPasswordPolicy() {
+ function passwordPolicyText(pass) {
var policy = '
';
- if (passRequirements.min) { policy += 'Minimum length: ' + passRequirements.min + '
'; }
- if (passRequirements.max) { policy += 'Maximum length: ' + passRequirements.max + '
'; }
- if (passRequirements.upper) { policy += 'Upper case: ' + passRequirements.upper + '
'; }
- if (passRequirements.lower) { policy += 'Lower case: ' + passRequirements.lower + '
'; }
- if (passRequirements.numeric) { policy += 'Numeric: ' + passRequirements.numeric + '
'; }
- if (passRequirements.nonalpha) { policy += 'Non-alphanumeric: ' + passRequirements.nonalpha + '
'; }
+ var counts = strCount(pass);
+ if (passRequirements.min && ((pass == null) || (pass.length < passRequirements.min))) { policy += 'Minimum length of ' + passRequirements.min + '
'; }
+ if (passRequirements.max && ((pass == null) || (pass.length > passRequirements.max))) { policy += 'Maximum length of ' + passRequirements.max + '
'; }
+ if (passRequirements.upper && ((pass == null) || (counts.upper < passRequirements.upper))) { policy += '' + passRequirements.upper + ' upper case
'; }
+ if (passRequirements.lower && ((pass == null) || (counts.lower < passRequirements.lower))) { policy += '' + passRequirements.lower + ' lower case
'; }
+ if (passRequirements.numeric && ((pass == null) || (counts.numeric < passRequirements.numeric))) { policy += '' + passRequirements.numeric + ' numeric
'; }
+ if (passRequirements.nonalpha && ((pass == null) || (counts.nonalpha < passRequirements.nonalpha))) { policy += passRequirements.nonalpha + ' non-alphanumeric
'; }
policy += '
';
- messagebox("Password Policy", policy);
+ return policy;
+ }
+
+ function showPasswordPolicy() {
+ messagebox("Password Policy", passwordPolicyText());
}
function validateReset(e) {
@@ -483,19 +493,25 @@
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;
diff --git a/webserver.js b/webserver.js
index 1277ab53..6a228ddf 100644
--- a/webserver.js
+++ b/webserver.js
@@ -1410,15 +1410,15 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
// Get total bytes in the path
var totalsize = readTotalFileSize(xfile.fullpath);
if ((xfile.quota == null) || (totalsize < xfile.quota)) { // Check if the quota is not already broken
-
- // See if we need to create the folder
- var domainx = 'domain';
- if (domain.id.length > 0) { domainx = 'domain-' + usersplit[1]; }
- try { obj.fs.mkdirSync(obj.parent.filespath); } catch (e) { }
- try { obj.fs.mkdirSync(obj.parent.path.join(obj.parent.filespath, domainx)); } catch (e) { }
- try { obj.fs.mkdirSync(xfile.fullpath); } catch (e) { }
-
if (fields.name != null) {
+
+ // See if we need to create the folder
+ var domainx = 'domain';
+ if (domain.id.length > 0) { domainx = 'domain-' + usersplit[1]; }
+ try { obj.fs.mkdirSync(obj.parent.filespath); } catch (e) { }
+ try { obj.fs.mkdirSync(obj.parent.path.join(obj.parent.filespath, domainx)); } catch (e) { }
+ try { obj.fs.mkdirSync(xfile.fullpath); } catch (e) { }
+
// Upload method where all the file data is within the fields.
var names = fields.name[0].split('*'), sizes = fields.size[0].split('*'), types = fields.type[0].split('*'), datas = fields.data[0].split('*');
if ((names.length == sizes.length) && (types.length == datas.length) && (names.length == types.length)) {
@@ -1443,6 +1443,14 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
for (var i in files.files) {
var file = files.files[i], fpath = obj.path.join(xfile.fullpath, file.originalFilename);
if (obj.common.IsFilenameValid(file.originalFilename) && ((xfile.quota == null) || ((totalsize + file.size) < xfile.quota))) { // Check if quota would not be broken if we add this file
+
+ // See if we need to create the folder
+ var domainx = 'domain';
+ if (domain.id.length > 0) { domainx = 'domain-' + usersplit[1]; }
+ try { obj.fs.mkdirSync(obj.parent.filespath); } catch (e) { }
+ try { obj.fs.mkdirSync(obj.parent.path.join(obj.parent.filespath, domainx)); } catch (e) { }
+ try { obj.fs.mkdirSync(xfile.fullpath); } catch (e) { }
+
obj.fs.rename(file.path, fpath, function () {
obj.parent.DispatchEvent([user._id], obj, 'updatefiles'); // Fire an event causing this user to update this files
});