Skip to content

Commit

Permalink
Blacklist a colon for users password (#110)
Browse files Browse the repository at this point in the history
A colon is currently not correctly handled by passport-http (see #108),
and until it is (see PR in the issue) a colon should not be used
in a password.
  • Loading branch information
FlorianSW authored and digitaldan committed Jul 16, 2017
1 parent 1b007f2 commit 4a12d0d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions userpassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ UserPassword.isComplexEnough = function(password) {
return false;
}

if (password.indexOf(':') !== -1) {
return false;
}

// match against all lowercase letters
if (password.match(/^(?=.*[a-z]).+$/)) {
matches++;
Expand All @@ -74,11 +78,7 @@ UserPassword.isComplexEnough = function(password) {
matches++;
}

if (matches < 2) {
return false;
}

return true;
return matches > 1;
};

/**
Expand All @@ -95,6 +95,7 @@ UserPassword.printPasswordNotComplexEnoughError = function(req) {
message.push(' * Uppercase letters (A, B, C, ...)');
message.push(' * Numbers (1, 2, 3, ...)');
message.push(' * Special characters out of: -+_!@#$%^&*.,?');
message.push(' * must not contain a colon (":")');

req.flash('error', message);
};
Expand Down

0 comments on commit 4a12d0d

Please sign in to comment.