--- loncom/interface/createaccount.pm 2019/08/25 13:55:55 1.72.4.3 +++ loncom/interface/createaccount.pm 2017/08/03 16:22:08 1.74 @@ -4,7 +4,7 @@ # kerberos, or SSO) or an e-mail address. Requests to use an e-mail address as # username may be processed automatically, or may be queued for approval. # -# $Id: createaccount.pm,v 1.72.4.3 2019/08/25 13:55:55 raeburn Exp $ +# $Id: createaccount.pm,v 1.74 2017/08/03 16:22:08 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -37,7 +37,6 @@ use Apache::lonacc; use Apache::lonnet; use Apache::loncommon; use Apache::lonhtmlcommon; -use Apache::lonuserutils; use Apache::lonlocal; use Apache::lonauth; use Apache::resetpw; @@ -329,7 +328,7 @@ sub handler { &print_header($r,$start_page,$courseid,$pagetitle); my $now=time; if ((grep(/^login$/,@{$cancreate})) && (!grep(/^email$/,@{$cancreate}))) { - if (open(my $jsh,"<","$include/londes.js")) { + if (open(my $jsh,"<$include/londes.js")) { while(my $line = <$jsh>) { $r->print($line); } @@ -521,12 +520,10 @@ ENDSCRIPT } sub javascript_checkpass { - my ($now,$context,$domain) = @_; + my ($now,$context) = @_; my $nopass = &mt('You must enter a password.'); my $mismatchpass = &mt('The passwords you entered did not match.')."\n". &mt('Please try again.'); - my ($numrules,$intargjs) = - &Apache::lonuserutils::passwd_validation_js('upass',$domain); &js_escape(\$nopass); &js_escape(\$mismatchpass); my $js = <<"ENDSCRIPT"; @@ -543,10 +540,6 @@ sub javascript_checkpass { return false; } if (upass == upasscheck) { - var numrules = $numrules; - if (numrules > 0) { -$intargjs - } client.elements.upasscheck$now.value=''; if (validate_email(client)) { send(one,two,'$context'); @@ -641,7 +634,7 @@ sub print_username_form { push(@posstypes,'default'); } $output .= '

'.&mt('Choose your affiliation at [_1]',$domdesc).'

'."\n". - '

'; foreach my $type (@posstypes) { my $name; @@ -655,11 +648,7 @@ sub print_username_form { } } } - my $checked; - if ($env{'form.type'} eq $type) { - $checked = ' checked="checked"'; - } - $output .= '

'. - &mt('[_1]Return[_2] to the previous page to try again.', - '','')."\n". - ''. - ''."\n"; - if ($env{'form.courseid'} =~ /^$match_domain\_$match_courseid$/) { - $output .= ''."\n"; - } - if ($env{'form.type'}) { - my $usertype = &get_usertype($domain); - if ($usertype ne '') { - $output .= ''."\n". - ''."\n"; - } - } - $output .= '

'; + $output = &invalid_state('captcha',$domdesc,$contact_name, + $contact_email,$captcha_error); return $output; } my (%rulematch,%inst_results,%curr_rules,%got_rules,%alerts); @@ -917,72 +878,16 @@ sub send_token { $env{'form.logtoken'} =~ s/(`)//g; if ($env{'form.logtoken'}) { my $logtoken = $env{'form.logtoken'}; - my $earlyout; my $tmpinfo=Apache::lonnet::reply('tmpget:'.$logtoken,$server); if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) { $msg = &mt('Information needed to process your request is missing, inaccessible or expired.') - .'

'.&mt('[_1]Return[_2] to the previous page to try again.', - '',''); - $earlyout = 1; + .'
'.&mt('Return to the previous page to try again.'); } else { my $reply = &Apache::lonnet::reply('tmpdel:'.$logtoken,$server); unless ($reply eq 'ok') { $msg .= &mt('Request could not be processed.'); } } -# Check if the password entered by the user satisfies domain's requirements - my %passwdconf = &Apache::lonnet::get_passwdconf($domain); - my ($min,$max,@chars); - $min = $Apache::lonnet::passwdmin; - if (ref($passwdconf{'chars'}) eq 'ARRAY') { - if ($passwdconf{'min'} =~ /^\d+$/) { - if ($passwdconf{'min'} > $min) { - $min = $passwdconf{'min'}; - } - } - if ($passwdconf{'max'} =~ /^\d+$/) { - $max = $passwdconf{'max'}; - } - @chars = @{$passwdconf{'chars'}}; - } - my $encpass = $env{'form.upass'}; - if ($encpass eq '') { - $msg = &mt('Password retrieved was blank.'). - '

'.&mt('[_1]Return[_2] to the previous page to try again.', - '',''); - $earlyout = 1; - } else { -# Split the logtoken to retrieve the DES key and decrypt the encypted password - my ($key,$caller)=split(/&/,$tmpinfo); - if ($caller eq 'createaccount') { - my $plainpass = &Apache::loncommon::des_decrypt($key,$encpass); - if (($min > 0) || ($max ne '') || (@chars > 0)) { - my $warning = &Apache::loncommon::check_passwd_rules($domain,$plainpass); - if ($warning) { - $msg = $warning. - '

'.&mt('[_1]Return[_2] to the previous page to try again.', - '',''); - $earlyout = 1; - } - } - } - } - if ($earlyout) { - $msg .= '

'. - ''."\n"; - if ($env{'form.courseid'} =~ /^$match_domain\_$match_courseid$/) { - $msg .= ''."\n"; - } - if ($env{'form.type'}) { - my $usertype = &get_usertype($domain); - if ($usertype ne '') { - $msg .= ''. - ''."\n"; - } - } - $msg .= '

'; - return $msg; - } my %info = ('ip' => $ENV{'REMOTE_ADDR'}, 'time' => $now, 'domain' => $domain, @@ -1168,14 +1073,14 @@ sub print_dataentry_form { my ($r,$domain,$lonhost,$include,$now,$captchaform,$courseid,$emailusername,$captcha, $usertype,$recaptchaversion,$usernameset,$condition,$excluded) = @_; my ($error,$output); - if (open(my $jsh,"<","$include/londes.js")) { + if (open(my $jsh,"<$include/londes.js")) { while(my $line = <$jsh>) { $r->print($line); } close($jsh); $output = &javascript_setforms($now,$emailusername,$captcha,$usertype,$recaptchaversion, $usernameset,$condition,$excluded). - "\n".&javascript_checkpass($now,'email',$domain); + "\n".&javascript_checkpass($now,'email'); my ($lkey,$ukey) = &Apache::loncommon::des_keys(); my ($lextkey,$uextkey) = &getkeys($lkey,$ukey); my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount:createaccount', @@ -1783,6 +1688,8 @@ sub invalid_state { $msg .= &mt('Username rules at this institution do not allow the e-mail address you provided to be used as a username.'); } elsif ($error eq 'userformat') { $msg .= &mt('The e-mail address you provided may not be used as a username at this LON-CAPA institution.'); + } elsif ($error eq 'captcha') { + $msg .= &mt('Validation of the code you entered failed.'); } elsif ($error eq 'noemails') { $msg .= &mt('Creation of a new user account using an e-mail address as username is not permitted at this LON-CAPA institution.'); } elsif ($error eq 'emailfail') { @@ -1963,14 +1870,14 @@ sub sso_logout_frag { if (defined($r->dir_config('lonSSOUserLogoutMessageFile_'.$domain))) { my $msgfile = $r->dir_config('lonSSOUserLogoutMessageFile_'.$domain); if (-e $msgfile) { - open(my $fh,"<",$msgfile); + open(my $fh,"<$msgfile"); $endsessionmsg = join('',<$fh>); close($fh); } } elsif (defined($r->dir_config('lonSSOUserLogoutMessageFile'))) { my $msgfile = $r->dir_config('lonSSOUserLogoutMessageFile'); if (-e $msgfile) { - open(my $fh,"<",$msgfile); + open(my $fh,"<$msgfile"); $endsessionmsg = join('',<$fh>); close($fh); } @@ -2089,7 +1996,6 @@ function checkVerification() { if (curr == types[j]) { if (!cancreate) { alert('Creation of an account via verification by e-mail unavailable for user type: "'+names[j]+'"'); - setElements(); } break; }