version 1.195, 2019/04/29 22:19:24
|
version 1.197, 2019/05/05 04:00:42
|
Line 438 sub javascript_validations {
|
Line 438 sub javascript_validations {
|
} elsif ($context eq 'domain') { |
} elsif ($context eq 'domain') { |
$setsection_call = 'setCourse()'; |
$setsection_call = 'setCourse()'; |
$setsections_js = &dc_setcourse_js($param{'formname'},$mode, |
$setsections_js = &dc_setcourse_js($param{'formname'},$mode, |
$context,$showcredits); |
$context,$showcredits,$domain); |
} |
} |
$finish = " var checkSec = $setsection_call\n". |
$finish = " var checkSec = $setsection_call\n". |
" if (checkSec == 'ok') {\n". |
" if (checkSec == 'ok') {\n". |
Line 531 END
|
Line 531 END
|
/* regexp here to check for non \d \. in credits */ |
/* regexp here to check for non \d \. in credits */ |
END |
END |
} else { |
} else { |
|
my ($numrules,$intargjs) = |
|
&passwd_validation_js('vf.elements[current.argfield].value',$domain); |
$auth_checks .= (<<END); |
$auth_checks .= (<<END); |
foundatype=1; |
foundatype=1; |
if (current.argfield == null || current.argfield == '') { |
if (current.argfield == null || current.argfield == '') { |
|
// The login radiobutton checked does not have an associated textbox |
|
} else if (vf.elements[current.argfield].value == '') { |
var alertmsg = ''; |
var alertmsg = ''; |
switch (current.radiovalue) { |
switch (current.radiovalue) { |
case 'krb': |
case 'krb': |
alertmsg = '$alert{'krb'}'; |
alertmsg = '$alert{'krb'}'; |
break; |
break; |
case 'loc': |
case 'loc': |
case 'fsys': |
case 'int': |
alertmsg = '$alert{'ipass'}'; |
alertmsg = '$alert{'ipass'}'; |
break; |
break; |
case 'fsys': |
case 'fsys': |
alertmsg = ''; |
alertmsg = '$alert{'ipass'}'; |
break; |
break; |
case 'lti': |
case 'lti': |
default: |
default: |
Line 554 END
|
Line 558 END
|
alert(alertmsg); |
alert(alertmsg); |
return; |
return; |
} |
} |
|
} else if (current.radiovalue == 'int') { |
|
if ($numrules > 0) { |
|
$intargjs |
|
} |
} |
} |
END |
END |
} |
} |
Line 642 END
|
Line 650 END
|
$section_checks.$authheader; |
$section_checks.$authheader; |
return $result; |
return $result; |
} |
} |
|
|
|
sub passwd_validation_js { |
|
my ($currpasswdval,$domain) = @_; |
|
my %passwdconf = &Apache::lonnet::get_passwdconf($domain); |
|
my ($min,$max,@chars,$numrules,$intargjs,%alert); |
|
$numrules = 0; |
|
if (ref($passwdconf{'chars'}) eq 'ARRAY') { |
|
if ($passwdconf{'min'} =~ /^\d+$/) { |
|
$min = $passwdconf{'min'}; |
|
$numrules ++; |
|
} |
|
if ($passwdconf{'max'} =~ /^\d+$/) { |
|
$max = $passwdconf{'max'}; |
|
$numrules ++; |
|
} |
|
@chars = @{$passwdconf{'chars'}}; |
|
if (@chars) { |
|
$numrules ++; |
|
} |
|
} else { |
|
$min = 7; |
|
$numrules ++; |
|
} |
|
if (($min ne '') || ($max ne '') || (@chars > 0)) { |
|
my $alertmsg = &mt('Initial password did not satisfy requirement(s):').'\n\n'; |
|
if ($min) { |
|
$alert{'min'} = &mt('minimum [quant,_1,character]',$min).'\n'; |
|
} |
|
if ($max) { |
|
$alert{'max'} = &mt('maximum [quant,_1,character]',$max).'\n'; |
|
} |
|
my (@charalerts,@charrules); |
|
if (@chars) { |
|
if (grep(/^uc$/,@chars)) { |
|
push(@charalerts,&mt('contain at least one upper case letter')); |
|
push(@charrules,'uc'); |
|
} |
|
if (grep(/^lc$/,@chars)) { |
|
push(@charalerts,&mt('contain at least one lower case letter')); |
|
push(@charrules,'lc'); |
|
} |
|
if (grep(/^num$/,@chars)) { |
|
push(@charalerts,&mt('contain at least one number')); |
|
push(@charrules,'num'); |
|
} |
|
if (grep(/^spec$/,@chars)) { |
|
push(@charalerts,&mt('contain at least one non-alphanumeric')); |
|
push(@charrules,'spec'); |
|
} |
|
} |
|
$intargjs = qq| var rulesmsg = '';\n|. |
|
qq| var currpwval = $currpasswdval;\n|; |
|
if ($min) { |
|
$intargjs .= qq| |
|
if (currpwval.length < $min) { |
|
rulesmsg += ' - $alert{min}'; |
|
} |
|
|; |
|
} |
|
if ($max) { |
|
$intargjs .= qq| |
|
if (currpwval.length > $max) { |
|
rulesmsg += ' - $alert{max}'; |
|
} |
|
|; |
|
} |
|
if (@chars > 0) { |
|
my $charrulestr = '"'.join('","',@charrules).'"'; |
|
my $charalertstr = '"'.join('","',@charalerts).'"'; |
|
$intargjs .= qq| var brokerules = new Array();\n|. |
|
qq| var charrules = new Array($charrulestr);\n|. |
|
qq| var charalerts = new Array($charalertstr);\n|; |
|
my %rules; |
|
map { $rules{$_} = 1; } @chars; |
|
if ($rules{'uc'}) { |
|
$intargjs .= qq| |
|
var ucRegExp = /[A-Z]/; |
|
if (!ucRegExp.test(currpwval)) { |
|
brokerules.push('uc'); |
|
} |
|
|; |
|
} |
|
if ($rules{'lc'}) { |
|
$intargjs .= qq| |
|
var lcRegExp = /[a-z]/; |
|
if (!lcRegExp.test(currpwval)) { |
|
brokerules.push('lc'); |
|
} |
|
|; |
|
} |
|
if ($rules{'num'}) { |
|
$intargjs .= qq| |
|
var numRegExp = /[0-9]/; |
|
if (!numRegExp.test(currpwval)) { |
|
brokerules.push('num'); |
|
} |
|
|; |
|
} |
|
if ($rules{'spec'}) { |
|
$intargjs .= q| |
|
var specRegExp = /[!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{\|}~]/; |
|
if (!specRegExp.test(currpwval)) { |
|
brokerules.push('spec'); |
|
} |
|
|; |
|
} |
|
$intargjs .= qq| |
|
if (brokerules.length > 0) { |
|
for (var i=0; i<brokerules.length; i++) { |
|
for (var j=0; j<charrules.length; j++) { |
|
if (brokerules[i] == charrules[j]) { |
|
rulesmsg += ' - '+charalerts[j]+'\\n'; |
|
break; |
|
} |
|
} |
|
} |
|
} |
|
|; |
|
} |
|
$intargjs .= qq| |
|
if (rulesmsg != '') { |
|
rulesmsg = '$alertmsg'+rulesmsg; |
|
alert(rulesmsg); |
|
return false; |
|
} |
|
|; |
|
} |
|
return ($numrules,$intargjs); |
|
} |
|
|
############################################################### |
############################################################### |
############################################################### |
############################################################### |
sub upload_manager_javascript_forward_associate { |
sub upload_manager_javascript_forward_associate { |
Line 6129 sub get_course_identity {
|
Line 6267 sub get_course_identity {
|
} |
} |
|
|
sub dc_setcourse_js { |
sub dc_setcourse_js { |
my ($formname,$mode,$context,$showcredits) = @_; |
my ($formname,$mode,$context,$showcredits,$domain) = @_; |
my ($dc_setcourse_code,$authen_check); |
my ($dc_setcourse_code,$authen_check); |
my $cctext = &Apache::lonnet::plaintext('cc'); |
my $cctext = &Apache::lonnet::plaintext('cc'); |
my $cotext = &Apache::lonnet::plaintext('co'); |
my $cotext = &Apache::lonnet::plaintext('co'); |
Line 6138 sub dc_setcourse_js {
|
Line 6276 sub dc_setcourse_js {
|
if ($mode eq 'upload') { |
if ($mode eq 'upload') { |
$role = 'courserole'; |
$role = 'courserole'; |
} else { |
} else { |
$authen_check = &verify_authen($formname,$context); |
$authen_check = &verify_authen($formname,$context,$domain); |
} |
} |
$dc_setcourse_code = (<<"SCRIPTTOP"); |
$dc_setcourse_code = (<<"SCRIPTTOP"); |
$authen_check |
$authen_check |
Line 6282 ENDSCRIPT
|
Line 6420 ENDSCRIPT
|
} |
} |
|
|
sub verify_authen { |
sub verify_authen { |
my ($formname,$context) = @_; |
my ($formname,$context,$domain) = @_; |
my %alerts = &authcheck_alerts(); |
my %alerts = &authcheck_alerts(); |
my $finish = "return 'ok';"; |
my $finish = "return 'ok';"; |
if ($context eq 'author') { |
if ($context eq 'author') { |
$finish = "document.$formname.submit();"; |
$finish = "document.$formname.submit();"; |
} |
} |
|
my ($numrules,$intargjs) = |
|
&passwd_validation_js('argpicked',$domain); |
my $outcome = <<"ENDSCRIPT"; |
my $outcome = <<"ENDSCRIPT"; |
|
|
function auth_check() { |
function auth_check() { |
Line 6321 function auth_check() {
|
Line 6461 function auth_check() {
|
break; |
break; |
case 'int': |
case 'int': |
alertmsg = '$alerts{'ipass'}'; |
alertmsg = '$alerts{'ipass'}'; |
|
break; |
case 'fsys': |
case 'fsys': |
alertmsg = '$alerts{'ipass'}'; |
alertmsg = '$alerts{'ipass'}'; |
break; |
break; |
Line 6334 function auth_check() {
|
Line 6475 function auth_check() {
|
alert(alertmsg); |
alert(alertmsg); |
return; |
return; |
} |
} |
|
} else if (logintype == 'int') { |
|
var numrules = $numrules; |
|
if (numrules > 0) { |
|
$intargjs |
|
} |
} |
} |
$finish |
$finish |
} |
} |