version 1.231, 2019/04/24 21:15:48
|
version 1.233, 2019/05/05 23:19:47
|
Line 1636 ENDERROR
|
Line 1636 ENDERROR
|
return 1; |
return 1; |
} |
} |
} else { |
} else { |
my %passwdconf = &Apache::lonnet::get_passwdconf($domain); |
my $warning = &Apache::loncommon::check_passwd_rule($domain,$newpass1); |
my ($min,$max,@chars,@brokerule); |
if ($warning) { |
if (ref($passwdconf{'chars'}) eq 'ARRAY') { |
|
if ($passwdconf{'min'} =~ /^\d+$/) { |
|
$min = $passwdconf{'min'}; |
|
} |
|
if ($passwdconf{'max'} =~ /^\d+$/) { |
|
$max = $passwdconf{'max'}; |
|
} |
|
@chars = @{$passwdconf{'chars'}}; |
|
} else { |
|
$min = 7; |
|
} |
|
if (($min) && (length($newpass1) < $min)) { |
|
push(@brokerule,'min'); |
|
} |
|
if (($max) && (length($newpass1) > $max)) { |
|
push(@brokerule,'max'); |
|
} |
|
if (@chars) { |
|
my %rules; |
|
map { $rules{$_} = 1; } @chars; |
|
if ($rules{'uc'}) { |
|
unless ($newpass1 =~ /[A-Z]/) { |
|
push(@brokerule,'uc'); |
|
} |
|
} |
|
if ($rules{'lc'}) { |
|
unless ($newpass1 =~ /a-z/) { |
|
push(@brokerule,'lc'); |
|
} |
|
} |
|
if ($rules{'num'}) { |
|
unless ($newpass1 =~ /\d/) { |
|
push(@brokerule,'num'); |
|
} |
|
} |
|
if ($rules{'spec'}) { |
|
unless ($newpass1 =~ /[!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~]/) { |
|
push(@brokerule,'spec'); |
|
} |
|
} |
|
} |
|
if (@brokerule) { |
|
my %rulenames = &Apache::lonlocal::texthash( |
|
uc => 'At least one upper case letter', |
|
lc => 'At least one lower case letter', |
|
num => 'At least one number', |
|
spec => 'At least one non-alphanumeric', |
|
); |
|
$rulenames{'uc'} .= ': ABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
|
$rulenames{'lc'} .= ': abcdefghijklmnopqrstuvwxyz'; |
|
$rulenames{'num'} .= ': 0123456789'; |
|
$rulenames{'spec'} .= ': !"\#$%&\'()*+,-./:;<=>?@[\]^_\`{|}~'; |
|
$rulenames{'min'} = &mt('Minimum password length: [_1]',$min); |
|
$rulenames{'max'} = &mt('Maximum password length: [_1]',$max); |
|
my $warning = &mt('Password did not satisfy the following:').'<ul>'; |
|
foreach my $rule ('min','max','uc','ls','num','spec') { |
|
if (grep(/^$rule$/,@brokerule)) { |
|
$warning .= '<li>'.$rulenames{$rule}.'</li>'; |
|
} |
|
} |
|
$warning .= '</ul>'; |
|
&passwordchanger($r,'<span class="LC_warning">'. |
&passwordchanger($r,'<span class="LC_warning">'. |
$warning. |
$warning. |
&mt('Please try again.').'</span>', |
&mt('Please try again.').'</span>', |
Line 1752 ENDERROR
|
Line 1691 ENDERROR
|
return $result; |
return $result; |
} |
} |
} else { |
} else { |
|
my $feedback; |
|
if ($result eq 'prioruse') { |
|
$feedback = &mt('Please enter a password that you have not used recently.'); |
|
} else { |
|
$feedback = &mt('Please make sure your old password was entered correctly.'); |
|
} |
$message = &Apache::lonhtmlcommon::confirm_success( |
$message = &Apache::lonhtmlcommon::confirm_success( |
&mt("The password for user [_1] was not changed.",'<i>'.$user.'</i>').' '.&mt('Please make sure your old password was entered correctly.'),1); |
&mt("The password for user [_1] was not changed.",'<i>'.$user.'</i>').' '.$feedback,1); |
$message=&Apache::loncommon::confirmwrapper($message); |
$message=&Apache::loncommon::confirmwrapper($message); |
&print_main_menu($r, $message); |
&print_main_menu($r, $message); |
if (ref($ended)) { |
if (ref($ended)) { |