summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrojanu <aliustek@gmail.com>2011-01-07 15:14:40 +0100
committerFrédéric Buclin <LpSolit@gmail.com>2011-01-07 15:14:40 +0100
commit02e52f810b396c5f367dc18b162d6a6724cab754 (patch)
tree9429ed4fc89321b9af16fbfbad7583514177786a /Bugzilla/User.pm
parentBug 255524: The duplicates table inherits no CSS classes when viewed in simpl... (diff)
downloadbugzilla-02e52f810b396c5f367dc18b162d6a6724cab754.tar.gz
bugzilla-02e52f810b396c5f367dc18b162d6a6724cab754.tar.bz2
bugzilla-02e52f810b396c5f367dc18b162d6a6724cab754.zip
Bug 558803: Add a parameter to specify the password complexity for new passwords
r/a=LpSolit
Diffstat (limited to 'Bugzilla/User.pm')
-rw-r--r--Bugzilla/User.pm13
1 files changed, 13 insertions, 0 deletions
diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm
index d15113959..eafda6563 100644
--- a/Bugzilla/User.pm
+++ b/Bugzilla/User.pm
@@ -1946,6 +1946,19 @@ sub validate_password {
} elsif ((defined $matchpassword) && ($password ne $matchpassword)) {
ThrowUserError('passwords_dont_match');
}
+
+ my $complexity_level = Bugzilla->params->{password_complexity};
+ if ($complexity_level eq 'letters_numbers_specialchars') {
+ ThrowUserError('password_not_complex')
+ if ($password !~ /\w/ || $password !~ /\d/ || $password !~ /[[:punct:]]/);
+ } elsif ($complexity_level eq 'letters_numbers') {
+ ThrowUserError('password_not_complex')
+ if ($password !~ /[[:lower:]]/ || $password !~ /[[:upper:]]/ || $password !~ /\d/);
+ } elsif ($complexity_level eq 'mixed_letters') {
+ ThrowUserError('password_not_complex')
+ if ($password !~ /[[:lower:]]/ || $password !~ /[[:upper:]]/);
+ }
+
# Having done these checks makes us consider the password untainted.
trick_taint($_[0]);
return 1;