--- loncom/interface/createaccount.pm 2019/05/05 04:00:42 1.77
+++ loncom/interface/createaccount.pm 2019/08/25 02:42:56 1.79
@@ -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.77 2019/05/05 04:00:42 raeburn Exp $
+# $Id: createaccount.pm,v 1.79 2019/08/25 02:42:56 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -842,8 +842,24 @@ sub process_email_request {
} else {
my ($captcha_chk,$captcha_error) = &Apache::loncommon::captcha_response('usercreation',$server);
if ($captcha_chk != 1) {
- $output = &invalid_state('captcha',$domdesc,$contact_name,
- $contact_email,$captcha_error);
+ $output = ''.
+ &mt('Validation of the code you entered failed.').''.
+ '
'.$captcha_error."\n".'
'. + &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 .= ''; return $output; } my (%rulematch,%inst_results,%curr_rules,%got_rules,%alerts); @@ -901,16 +917,72 @@ 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;
} 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, @@ -1711,8 +1783,6 @@ 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') {