version 1.364, 2019/07/23 01:30:35
|
version 1.365, 2019/08/25 02:42:55
|
Line 6256 sub print_passwords {
|
Line 6256 sub print_passwords {
|
} |
} |
} elsif ($position eq 'lower') { |
} elsif ($position eq 'lower') { |
my ($min,$max,%chars,$expire,$numsaved); |
my ($min,$max,%chars,$expire,$numsaved); |
|
$min = $Apache::lonnet::passwdmin; |
if (ref($settings) eq 'HASH') { |
if (ref($settings) eq 'HASH') { |
if ($settings->{min}) { |
if ($settings->{min}) { |
$min = $settings->{min}; |
$min = $settings->{min}; |
Line 6272 sub print_passwords {
|
Line 6273 sub print_passwords {
|
if ($settings->{numsaved}) { |
if ($settings->{numsaved}) { |
$numsaved = $settings->{numsaved}; |
$numsaved = $settings->{numsaved}; |
} |
} |
} else { |
|
$min = '7'; |
|
} |
} |
my %rulenames = &Apache::lonlocal::texthash( |
my %rulenames = &Apache::lonlocal::texthash( |
uc => 'At least one upper case letter', |
uc => 'At least one upper case letter', |
Line 6284 sub print_passwords {
|
Line 6283 sub print_passwords {
|
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$datatable .= '<tr'.$css_class.'><td>'.$titles{'min'}.'</td>'. |
$datatable .= '<tr'.$css_class.'><td>'.$titles{'min'}.'</td>'. |
'<td class="LC_left_item"><span class="LC_nobreak">'. |
'<td class="LC_left_item"><span class="LC_nobreak">'. |
'<input type="text" name="passwords_min" value="'.$min.'" size="3" />'. |
'<input type="text" name="passwords_min" value="'.$min.'" size="3" '. |
'<span class="LC_fontsize_small"> '.&mt('(Leave blank for no minimum)').'</span>'. |
'onblur="javascript:warnIntPass(this);" />'. |
|
'<span class="LC_fontsize_small"> '.&mt('(Enter an integer: 7 or larger)').'</span>'. |
'</span></td></tr>'; |
'</span></td></tr>'; |
$itemcount ++; |
$itemcount ++; |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$datatable .= '<tr'.$css_class.'><td>'.$titles{'max'}.'</td>'. |
$datatable .= '<tr'.$css_class.'><td>'.$titles{'max'}.'</td>'. |
'<td class="LC_left_item"><span class="LC_nobreak">'. |
'<td class="LC_left_item"><span class="LC_nobreak">'. |
'<input type="text" name="passwords_max" value="'.$max.'" size="3" />'. |
'<input type="text" name="passwords_max" value="'.$max.'" size="3" '. |
|
'onblur="javascript:warnIntPass(this);" />'. |
'<span class="LC_fontsize_small"> '.&mt('(Leave blank for no maximum)').'</span>'. |
'<span class="LC_fontsize_small"> '.&mt('(Leave blank for no maximum)').'</span>'. |
'</span></td></tr>'; |
'</span></td></tr>'; |
$itemcount ++; |
$itemcount ++; |
Line 6331 sub print_passwords {
|
Line 6332 sub print_passwords {
|
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$datatable .= '<tr'.$css_class.'><td>'.$titles{'expire'}.'</td>'. |
$datatable .= '<tr'.$css_class.'><td>'.$titles{'expire'}.'</td>'. |
'<td class="LC_left_item"><span class="LC_nobreak">'. |
'<td class="LC_left_item"><span class="LC_nobreak">'. |
'<input type="text" name="passwords_expire" value="'.$expire.'" size="4" />'. |
'<input type="text" name="passwords_expire" value="'.$expire.'" size="4" '. |
|
'onblur="javascript:warnIntPass(this);" />'. |
'<span class="LC_fontsize_small"> '.&mt('(Leave blank for no expiration)').'</span>'. |
'<span class="LC_fontsize_small"> '.&mt('(Leave blank for no expiration)').'</span>'. |
'</span></td></tr>'; |
'</span></td></tr>'; |
$itemcount ++; |
$itemcount ++; |
Line 9295 ENDSCRIPT
|
Line 9297 ENDSCRIPT
|
} |
} |
|
|
sub passwords_javascript { |
sub passwords_javascript { |
my $intauthcheck = &mt('Warning: disallowing login for an authenticated user if the stored cost is less than the default will require a password reset by/for the user.'); |
my %intalert = &Apache::lonlocal::texthash ( |
my $intauthcost = &mt('Warning: bcrypt encryption cost for internal authentication must be an integer.'); |
authcheck => 'Warning: disallowing login for an authenticated user if the stored cost is less than the default will require a password reset by/for the user.', |
&js_escape(\$intauthcheck); |
authcost => 'Warning: bcrypt encryption cost for internal authentication must be an integer.', |
&js_escape(\$intauthcost); |
passmin => 'Warning: minimum password length must be a positive integer greater than 6.', |
|
passmax => 'Warning: maximum password length must be a positive integer (or blank).', |
|
passexp => 'Warning: days before password expiration must be a positive integer (or blank).', |
|
passnum => 'Warning: number of previous passwords to save must be a positive integer (or blank).', |
|
); |
|
&js_escape(\%intalert); |
|
my $defmin = $Apache::lonnet::passwdmin; |
my $intauthjs = <<"ENDSCRIPT"; |
my $intauthjs = <<"ENDSCRIPT"; |
|
|
function warnIntAuth(field) { |
function warnIntAuth(field) { |
if (field.name == 'intauth_check') { |
if (field.name == 'intauth_check') { |
if (field.value == '2') { |
if (field.value == '2') { |
alert('$intauthcheck'); |
alert('$intalert{authcheck}'); |
} |
} |
} |
} |
if (field.name == 'intauth_cost') { |
if (field.name == 'intauth_cost') { |
Line 9312 function warnIntAuth(field) {
|
Line 9320 function warnIntAuth(field) {
|
if (field.value != '') { |
if (field.value != '') { |
var regexdigit=/^\\d+\$/; |
var regexdigit=/^\\d+\$/; |
if (!regexdigit.test(field.value)) { |
if (!regexdigit.test(field.value)) { |
alert('$intauthcost'); |
alert('$intalert{authcost}'); |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
function warnIntPass(field) { |
|
field.value.replace(/^\s+/,''); |
|
field.value.replace(/\s+\$/,''); |
|
var regexdigit=/^\\d+\$/; |
|
if (field.name == 'passwords_min') { |
|
if (field.value == '') { |
|
alert('$intalert{passmin}'); |
|
field.value = '$defmin'; |
|
} else { |
|
if (!regexdigit.test(field.value)) { |
|
alert('$intalert{passmin}'); |
|
field.value = '$defmin'; |
|
} |
|
var minval = parseFloat(field.value,10); |
|
if (minval < $defmin) { |
|
alert('$intalert{passmin}'); |
|
field.value = '$defmin'; |
|
} |
|
} |
|
} else { |
|
if (field.value == '0') { |
|
field.value = ''; |
|
} |
|
if (field.value != '') { |
|
if (field.name == 'passwords_expire') { |
|
var regexpposnum=/^\\d+(|\\.\\d*)\$/; |
|
if (!regexpposnum.test(field.value)) { |
|
alert('$intalert{passexp}'); |
|
field.value = ''; |
|
} else { |
|
var expval = parseFloat(field.value); |
|
if (expval == 0) { |
|
alert('$intalert{passexp}'); |
|
field.value = ''; |
|
} |
|
} |
|
} else { |
|
if (!regexdigit.test(field.value)) { |
|
if (field.name == 'passwords_max') { |
|
alert('$intalert{passmax}'); |
|
} else { |
|
if (field.name == 'passwords_numsaved') { |
|
alert('$intalert{passnum}'); |
|
} |
|
} |
|
} |
|
field.value = ''; |
} |
} |
} |
} |
} |
} |
Line 14490 sub modify_passwords {
|
Line 14551 sub modify_passwords {
|
'intauth_cost' => 10, |
'intauth_cost' => 10, |
'intauth_check' => 0, |
'intauth_check' => 0, |
'intauth_switch' => 0, |
'intauth_switch' => 0, |
'min' => 7, |
|
); |
); |
|
$staticdefaults{'min'} = $Apache::lonnet::passwdmin; |
foreach my $type (@oktypes) { |
foreach my $type (@oktypes) { |
$staticdefaults{'resetpostlink'}{$type} = ['email','username']; |
$staticdefaults{'resetpostlink'}{$type} = ['email','username']; |
} |
} |
Line 14672 sub modify_passwords {
|
Line 14733 sub modify_passwords {
|
$env{'form.passwords_'.$rule} =~ s/^\s+|\s+$//g; |
$env{'form.passwords_'.$rule} =~ s/^\s+|\s+$//g; |
my $ruleok; |
my $ruleok; |
if ($rule eq 'expire') { |
if ($rule eq 'expire') { |
if ($env{'form.passwords_'.$rule} =~ /^\d+(|\.\d*)$/) { |
if (($env{'form.passwords_'.$rule} =~ /^\d+(|\.\d*)$/) && |
|
($env{'form.passwords_'.$rule} ne '0')) { |
$ruleok = 1; |
$ruleok = 1; |
} |
} |
} elsif ($env{'form.passwords_'.$rule} =~ /^\d+$/) { |
} elsif ($rule eq 'min') { |
|
if ($env{'form.passwords_'.$rule} =~ /^\d+$/) { |
|
if ($env{'form.passwords_'.$rule} >= $Apache::lonnet::passwdmin) { |
|
$ruleok = 1; |
|
} |
|
} |
|
} elsif (($env{'form.passwords_'.$rule} =~ /^\d+$/) && |
|
($env{'form.passwords_'.$rule} ne '0')) { |
$ruleok = 1; |
$ruleok = 1; |
} |
} |
if ($ruleok) { |
if ($ruleok) { |
Line 14885 sub modify_passwords {
|
Line 14954 sub modify_passwords {
|
if ($confighash{'passwords'}{$rule} eq '') { |
if ($confighash{'passwords'}{$rule} eq '') { |
if ($rule eq 'min') { |
if ($rule eq 'min') { |
$resulttext .= '<li>'.&mt('[_1] not set.',$titles{$rule}); |
$resulttext .= '<li>'.&mt('[_1] not set.',$titles{$rule}); |
' '.&mt('Default of 7 will be used').'</li>'; |
' '.&mt('Default of [_1] will be used', |
|
$Apache::lonnet::passwdmin).'</li>'; |
} else { |
} else { |
$resulttext .= '<li>'.&mt('[_1] set to none',$titles{$rule}).'</li>'; |
$resulttext .= '<li>'.&mt('[_1] set to none',$titles{$rule}).'</li>'; |
} |
} |