version 1.229, 2019/04/24 02:00:23
|
version 1.231, 2019/04/24 21:15:48
|
Line 27
|
Line 27
|
# |
# |
# This package uses the "londes.js" javascript code. |
# This package uses the "londes.js" javascript code. |
# |
# |
# TODOs that have to be completed: |
|
# interface with lonnet to change the password |
|
|
|
package Apache::lonpreferences; |
package Apache::lonpreferences; |
|
|
Line 1312 sub passwordchanger {
|
Line 1310 sub passwordchanger {
|
); |
); |
return; |
return; |
} |
} |
} else { |
} else { |
$r->print( |
$r->print( |
'<p class="LC_warning">' |
'<p class="LC_warning">' |
.&mt('Sorry, the URL generated when you requested reset of' |
.&mt('Sorry, the URL generated when you requested reset of' |
Line 1621 ENDERROR
|
Line 1619 ENDERROR
|
&mt('Please try again.').'</span>',$caller,$mailtoken); |
&mt('Please try again.').'</span>',$caller,$mailtoken); |
return 1; |
return 1; |
} |
} |
} |
} |
if ($newpass1 ne $newpass2) { |
if ($newpass1 ne $newpass2) { |
&passwordchanger($r, |
&passwordchanger($r, |
'<span class="LC_warning">'. |
'<span class="LC_warning">'. |
Line 1629 ENDERROR
|
Line 1627 ENDERROR
|
&mt('Please try again.').'</span>',$caller,$mailtoken); |
&mt('Please try again.').'</span>',$caller,$mailtoken); |
return 1; |
return 1; |
} |
} |
if (length($newpass1) < 7) { |
if ($currentauth eq 'unix:') { |
&passwordchanger($r, |
if (length($newpass1) < 7) { |
'<span class="LC_warning">'. |
&passwordchanger($r, |
&mt('Passwords must be a minimum of 7 characters long.').' '. |
'<span class="LC_warning">'. |
&mt('Please try again.').'</span>',$caller,$mailtoken); |
&mt('Passwords must be a minimum of 7 characters long.').' '. |
return 1; |
&mt('Please try again.').'</span>',$caller,$mailtoken); |
|
return 1; |
|
} |
|
} else { |
|
my %passwdconf = &Apache::lonnet::get_passwdconf($domain); |
|
my ($min,$max,@chars,@brokerule); |
|
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">'. |
|
$warning. |
|
&mt('Please try again.').'</span>', |
|
$caller,$mailtoken); |
|
return 1; |
|
} |
} |
} |
# |
# |
# Check for bad characters |
# Check for bad characters |