Diff for /loncom/interface/createaccount.pm between versions 1.77 and 1.90

version 1.77, 2019/05/05 04:00:42 version 1.90, 2025/02/18 17:45:11
Line 37  use Apache::lonacc; Line 37  use Apache::lonacc;
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::loncommon;  use Apache::loncommon;
 use Apache::lonhtmlcommon;  use Apache::lonhtmlcommon;
 use Apache::lonuserutils;  
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonauth;  use Apache::lonauth;
 use Apache::resetpw;  use Apache::resetpw;
Line 95  sub handler { Line 94  sub handler {
     my $lonhost = $r->dir_config('lonHostID');      my $lonhost = $r->dir_config('lonHostID');
     my $include = $r->dir_config('lonIncludes');      my $include = $r->dir_config('lonIncludes');
     my $start_page;      my $start_page;
       my $args = {};
   
       (undef,undef,undef,my $clientmathml,my $clientunicode) =
           &Apache::loncommon::decode_user_agent();
       if ($clientunicode && !$clientmathml) {
           $args->{'browser.unicode'} = 1;
       }
     my $handle = &Apache::lonnet::check_for_valid_session($r);      my $handle = &Apache::lonnet::check_for_valid_session($r);
     if (($handle ne '') && ($handle !~ /^publicuser_\d+$/)) {      if (($handle ne '') && ($handle !~ /^publicuser_\d+$/)) {
         $start_page =          $start_page =
             &Apache::loncommon::start_page('Already logged in');              &Apache::loncommon::start_page('Already logged in',undef,$args);
         my $end_page =          my $end_page =
             &Apache::loncommon::end_page();              &Apache::loncommon::end_page();
         $r->print($start_page."\n".'<h2>'.&mt('You are already logged in').'</h2>'.          $r->print($start_page."\n".'<div class="LC_landmark" role="main">'.
                     '<h2 class="LC_heading_2">'.&mt('You are already logged in').'</h2>'.
                   '<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',                    '<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',
                             '<a href="/adm/roles">','</a>','<a href="/adm/logout">','</a>').                              '<a href="/adm/roles">','</a>','<a href="/adm/logout">','</a>').
                   '</p><p><a href="/adm/loginproblems.html">'.&mt('Login problems?').'</a></p>'.$end_page);                    '</p><p><a href="/adm/loginproblems.html">'.&mt('Login problems?').'</a></p></div>'.$end_page);
         return OK;          return OK;
     }      }
   
Line 140  sub handler { Line 146  sub handler {
             &print_footer($r);              &print_footer($r);
             return OK;              return OK;
         } else {          } else {
             $start_page = &Apache::loncommon::start_page($title,$js);               $start_page = &Apache::loncommon::start_page($title,$js,$args); 
             &print_header($r,$start_page,$courseid);              &print_header($r,$start_page,$courseid);
             $r->print($output);              $r->print($output);
             &print_footer($r);                  &print_footer($r);    
Line 153  sub handler { Line 159  sub handler {
     my ($cancreate,$statustocreate,$statusforemail,$emailusername,      my ($cancreate,$statustocreate,$statusforemail,$emailusername,
         $emailoptions,$verification,$emaildomain,$types,$usertypes,$othertitle) =          $emailoptions,$verification,$emaildomain,$types,$usertypes,$othertitle) =
         &get_creation_controls($domain,$domconfig{'usercreation'});          &get_creation_controls($domain,$domconfig{'usercreation'});
     my ($additems,$pagetitle);      my ($pagetitle,$need_affiliation);
     if (ref($cancreate) eq 'ARRAY') {      if (ref($cancreate) eq 'ARRAY') {
         unless (($env{'form.token'}) || ($sso_username ne '') || ($env{'form.phase'}) ||          unless (($env{'form.token'}) || ($sso_username ne '') || ($env{'form.phase'}) ||
                 ($env{'form.create_with_email'})) {                  ($env{'form.create_with_email'})) {
Line 162  sub handler { Line 168  sub handler {
                 if ((($usertype eq '') || (!grep(/^\Q$usertype\E$/,@{$statusforemail}))) &&                   if ((($usertype eq '') || (!grep(/^\Q$usertype\E$/,@{$statusforemail}))) && 
                     (@{$statusforemail} > 0)) {                      (@{$statusforemail} > 0)) {
                     $js .= &setelements_js($statusforemail,$types,$usertypes,$othertitle);                      $js .= &setelements_js($statusforemail,$types,$usertypes,$othertitle);
                     $additems = {'add_entries' => { 'onload' => "setElements();"} };                      $args->{'add_entries'} = { 'onload' => "setElements();"};
                     if ((@{$cancreate} == 1) && (@{$statusforemail} > 0)) {                      if ((@{$cancreate} == 1) && (@{$statusforemail} > 0)) {
                         $pagetitle = 'Select affiliation';                          $pagetitle = 'Select affiliation';
                     }                      }
                       $need_affiliation = 1;
                 } else {                  } else {
                     $js .= &username_js();                      $js .= &username_js();
                 }                  }
             }              }
         }          }
     }      }
     $start_page = &Apache::loncommon::start_page($title,$js,$additems);      $start_page = &Apache::loncommon::start_page($title,$js,$args);
     if (@{$cancreate} == 0) {      if (@{$cancreate} == 0) {
         &print_header($r,$start_page,$courseid,$pagetitle);          &print_header($r,$start_page,$courseid,$pagetitle);
         my $output = '<h3>'.&mt('Account creation unavailable').'</h3>'.          my $output = '<h2 class="LC_heading_2">'.&mt('Account creation unavailable').'</h2>'.
                      '<span class="LC_warning">'.                       '<span class="LC_warning">'.
                      &mt('Creation of a new user account using an institutional log-in ID or e-mail verification is not permitted for: [_1].',$domdesc).                       &mt('Creation of a new user account using an institutional log-in ID or e-mail verification is not permitted for: [_1].',$domdesc).
                      '</span><br /><br />';                       '</span><br /><br />';
Line 189  sub handler { Line 196  sub handler {
         my ($msg,$sso_logout);          my ($msg,$sso_logout);
         $sso_logout = &sso_logout_frag($r,$domain);          $sso_logout = &sso_logout_frag($r,$domain);
         if (grep(/^sso$/,@{$cancreate})) {          if (grep(/^sso$/,@{$cancreate})) {
             $msg = '<h3>'.&mt('Account creation').'</h3>'.              $msg = '<h2 class="LC_heading_2">'.&mt('Account creation').'</h2>'.
                    &mt("Although your username and password were authenticated by your institution's Single Sign On system, you do not currently have a LON-CAPA account at this institution.").'<br />';                     &mt("Although your username and password were authenticated by your institution's Single Sign On system, you do not currently have a LON-CAPA account at this institution.").'<br />';
             my $shibenv;              my $shibenv;
             if (($r->dir_config('lonOtherAuthen') eq 'yes') &&               if (($r->dir_config('lonOtherAuthen') eq 'yes') && 
Line 223  sub handler { Line 230  sub handler {
                                     $lonhost,$contact_email,$contact_name,                                      $lonhost,$contact_email,$contact_name,
                                     $sso_logout,$statustocreate,$shibenv);                                      $sso_logout,$statustocreate,$shibenv);
         } else {          } else {
             $msg = '<h3>'.&mt('Account creation unavailable').'</h3>'.              $msg = '<h2 class="LC_heading_2">'.&mt('Account creation unavailable').'</h2>'.
                    '<span class="LC_warning">'.&mt("Although your username and password were authenticated by your institution's Single Sign On system, you do not currently have a LON-CAPA account at this institution, and you are not permitted to create one.").'</span><br /><br />'.&mt('Please contact the [_1] ([_2]) for assistance.',$contact_name,$contact_email).'<hr />'.                     '<span class="LC_warning">'.&mt("Although your username and password were authenticated by your institution's Single Sign On system, you do not currently have a LON-CAPA account at this institution, and you are not permitted to create one.").'</span><br /><br />'.&mt('Please contact the [_1] ([_2]) for assistance.',$contact_name,$contact_email).'<hr />'.
                    $sso_logout;                     $sso_logout;
         }          }
Line 328  sub handler { Line 335  sub handler {
     } elsif (!$token) {      } elsif (!$token) {
         &print_header($r,$start_page,$courseid,$pagetitle);          &print_header($r,$start_page,$courseid,$pagetitle);
         my $now=time;          my $now=time;
         if ((grep(/^login$/,@{$cancreate})) && (!grep(/^email$/,@{$cancreate}))) {          if ((grep(/^login$/,@{$cancreate})) &&
               ((!grep(/^email$/,@{$cancreate})) || ($need_affiliation))) {
             if (open(my $jsh,"<","$include/londes.js")) {              if (open(my $jsh,"<","$include/londes.js")) {
                 while(my $line = <$jsh>) {                  while(my $line = <$jsh>) {
                     $r->print($line);                      $r->print($line);
Line 438  sub javascript_setforms { Line 446  sub javascript_setforms {
                 }                  }
                 $setuserinfo .= '                    server.elements.'.$key.'.value=client.elements.'.$key.'.value;'."\n";                  $setuserinfo .= '                    server.elements.'.$key.'.value=client.elements.'.$key.'.value;'."\n";
             }              }
             $setuserinfo .= '                    server.elements.type.value=client.elements.type.value;'."\n";               if ($usertype ne '') {
                   $setuserinfo .= '                    server.elements.type.value=client.elements.type.value;'."\n";
               }
         }          }
         if ($captcha eq 'original') {          if ($captcha eq 'original') {
             $setuserinfo .= '                    server.elements.code.value=client.elements.code.value;'."\n".              $setuserinfo .= '                    server.elements.code.value=client.elements.code.value;'."\n".
Line 526  sub javascript_checkpass { Line 536  sub javascript_checkpass {
     my $mismatchpass = &mt('The passwords you entered did not match.')."\n".      my $mismatchpass = &mt('The passwords you entered did not match.')."\n".
                        &mt('Please try again.');                          &mt('Please try again.'); 
     my ($numrules,$intargjs) =      my ($numrules,$intargjs) =
         &Apache::lonuserutils::passwd_validation_js('upass',$domain);          &Apache::loncommon::passwd_validation_js('upass',$domain);
     &js_escape(\$nopass);      &js_escape(\$nopass);
     &js_escape(\$mismatchpass);      &js_escape(\$mismatchpass);
     my $js = <<"ENDSCRIPT";      my $js = <<"ENDSCRIPT";
Line 570  sub javascript_validmail { Line 580  sub javascript_validmail {
     my %js_lt = &Apache::lonlocal::texthash (      my %js_lt = &Apache::lonlocal::texthash (
                email => 'The e-mail address you entered',                 email => 'The e-mail address you entered',
                notv  => 'is not a valid e-mail address',                 notv  => 'is not a valid e-mail address',
                avae  => 'A valid e-mail address is not formed when the value you entered',                 avae  => 'A valid e-mail address is not formed when the value you entered is combined with the required domain',
                isco  => 'is combined with the required domain',  
     );      );
     my $output =  "\n".'<script type="text/javascript">'."\n".      my $output =  "\n".'<script type="text/javascript">'."\n".
                   '// <![CDATA['."\n".                    '// <![CDATA['."\n".
Line 583  function validate_email(client) { Line 592  function validate_email(client) {
     var condition = '$condition';      var condition = '$condition';
     if (validmail(field,condition) == false) {      if (validmail(field,condition) == false) {
         if ((condition != undefined) && (condition != '')) {          if ((condition != undefined) && (condition != '')) {
             alert("$js_lt{'avae'}: "+field.value+" $js_lt{'isco'}: "+condition);              alert("$js_lt{'avae'}: "+condition);
         } else {          } else {
             alert("$js_lt{'email'}: "+field.value+" $js_lt{'notv'}.");              alert("$js_lt{'email'}: "+field.value+" $js_lt{'notv'}.");
         }          }
Line 614  sub print_username_form { Line 623  sub print_username_form {
         if (grep(/^login$/,@{$cancreate})) {          if (grep(/^login$/,@{$cancreate})) {
             my %domdefaults = &Apache::lonnet::get_domain_defaults($domain);              my %domdefaults = &Apache::lonnet::get_domain_defaults($domain);
             if ((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth')) {              if ((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth')) {
                 $output = '<div class="LC_left_float"><h3>'.$lt{'crac'}.'</h3>';                  $output = '<div class="LC_left_float"><h2 class="LC_heading_2">'.$lt{'crac'}.'</h2>';
                 $output .= &mt('If you already have a log-in ID at this institution [_1]you may be able to use it for LON-CAPA.','<br />').                  $output .= &mt('If you already have a log-in ID at this institution [_1]you may be able to use it for LON-CAPA.','<br />').
                            '<br /><br />'.                             '<br /><br />'.
                            $lt{'type'}.                             $lt{'type'}.
Line 624  sub print_username_form { Line 633  sub print_username_form {
             }              }
         }          }
         if (grep(/^email$/,@{$cancreate})) {          if (grep(/^email$/,@{$cancreate})) {
             $output .= '<div class="LC_left_float"><h3>'.$lt{'crae'}.'</h3>';              $output .= '<div class="LC_left_float"><h2 class="LC_heading_2">'.$lt{'crae'}.'</h2>';
             if ($usertype ne '') {              if ($usertype ne '') {
                 if ((ref($statusforemail) eq 'ARRAY') && (@{$statusforemail} > 0)) {                  if ((ref($statusforemail) eq 'ARRAY') && (@{$statusforemail} > 0)) {
                     unless (grep(/^\Q$usertype\E$/,@{$statusforemail})) {                      unless (grep(/^\Q$usertype\E$/,@{$statusforemail})) {
Line 640  sub print_username_form { Line 649  sub print_username_form {
                 unless (grep(/^default$/,@posstypes)) {                  unless (grep(/^default$/,@posstypes)) {
                     push(@posstypes,'default');                      push(@posstypes,'default');
                 }                  }
                 $output .= '<p>'.&mt('Choose your affiliation at [_1]',$domdesc).'</p>'."\n".                  $output .= '<form name="reportstatus" id="LC_reportstatus" action="/adm/createaccount" method="post" '.
                            '<form name="reportstatus" id="LC_reportstatus" action="/adm/createaccount" method="post" '.                             'onsubmit="return checkVerification();"><fieldset><legend>'.
                            'onsubmit="return checkVerification();"><p>';                             &mt('Choose your affiliation at [_1]',$domdesc).'</legend>';
                 foreach my $type (@posstypes) {                  foreach my $type (@posstypes) {
                     my $name;                      my $name;
                     if ($type eq 'default') {                      if ($type eq 'default') {
Line 665  sub print_username_form { Line 674  sub print_username_form {
                 if ($env{'form.courseid'} =~ /^$match_domain\_$match_courseid$/) {                  if ($env{'form.courseid'} =~ /^$match_domain\_$match_courseid$/) {
                     $output .= "\n".'<input type="hidden" name="courseid" value="'.$env{'form.courseid'}.'" />';                      $output .= "\n".'<input type="hidden" name="courseid" value="'.$env{'form.courseid'}.'" />';
                 }                  }
                 $output .= '</p>'."\n".'<p><input type="submit" name="reportedtype" value="'.&mt('Submit').'" /></p></form>';                  $output .= "\n".'<p><input type="submit" name="reportedtype" value="'.&mt('Submit').'" />'.
                              '</p></fieldset></form>'."\n";
             } else {              } else {
                 my ($captchaform,$error,$captcha,$recaptchaversion) =                   my ($captchaform,$error,$captcha,$recaptchaversion) = 
                     &Apache::loncommon::captcha_display('usercreation',$lonhost);                      &Apache::loncommon::captcha_display('usercreation',$lonhost);
Line 739  sub login_box { Line 749  sub login_box {
     my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount:createaccount',      my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount:createaccount',
                                        $lonhost);                                         $lonhost);
     $output = &serverform($logtoken,$lonhost,undef,$courseid,$context);      $output = &serverform($logtoken,$lonhost,undef,$courseid,$context);
     my $unameform = '<input type="text" name="uname" size="20" value="" autocomplete="off" />';      my $unameform = '<input type="text" name="uname" id="uname" size="20" value="" autocomplete="off" />';
     my $upassform = '<input type="password" name="upass'.$now.'" size="20" autocomplete="off" />';      my $upassform = '<input type="password" name="upass'.$now.'" id="upass'.$now.'" size="20" autocomplete="new-password" />';
     $output .= '<form name="client" method="post" action="" onsubmit="return(send('."'server','client'".'));">'."\n".      $output .= '<form name="client" method="post" action="" onsubmit="return(send('."'server','client'".'));">'."\n".
                &Apache::lonhtmlcommon::start_pick_box()."\n".                 &Apache::lonhtmlcommon::start_pick_box()."\n".
                &Apache::lonhtmlcommon::row_title($titles{$context},                 &Apache::lonhtmlcommon::row_title('<label for="uname">'.$titles{$context}.'</label>',
                                                  'LC_pick_box_title')."\n".                                                   'LC_pick_box_title')."\n".
                $unameform."\n".                 $unameform."\n".
                &Apache::lonhtmlcommon::row_closure(1)."\n".                 &Apache::lonhtmlcommon::row_closure(1)."\n".
                &Apache::lonhtmlcommon::row_title(&mt('Password'),                 &Apache::lonhtmlcommon::row_title('<label for="upass'.$now.'">'.&mt('Password').'</label>',
                                                 'LC_pick_box_title')."\n".                                                  'LC_pick_box_title')."\n".
                $upassform;                 $upassform;
     if ($context eq 'selfenroll') {      if ($context eq 'selfenroll') {
Line 761  sub login_box { Line 771  sub login_box {
         $output .= '<input type="hidden" name="udom" value="'.$domain.'" />';          $output .= '<input type="hidden" name="udom" value="'.$domain.'" />';
     }      }
     $output .= &Apache::lonhtmlcommon::row_closure(1).      $output .= &Apache::lonhtmlcommon::row_closure(1).
                &Apache::lonhtmlcommon::row_title().                 &Apache::lonhtmlcommon::row_title('<span class="LC_visually_hidden">'.
                                                    &mt('Submit').'</span>','','','',1).
                '<br /><input type="submit" name="username_validation" value="'.                 '<br /><input type="submit" name="username_validation" value="'.
                $submit_text.'" />'."\n";                 $submit_text.'" />'."\n";
     if ($context eq 'selfenroll') {      if ($context eq 'selfenroll') {
Line 842  sub process_email_request { Line 853  sub process_email_request {
             } else {              } else {
                 my ($captcha_chk,$captcha_error) = &Apache::loncommon::captcha_response('usercreation',$server);                  my ($captcha_chk,$captcha_error) = &Apache::loncommon::captcha_response('usercreation',$server);
                 if ($captcha_chk != 1) {                  if ($captcha_chk != 1) {
                     $output = &invalid_state('captcha',$domdesc,$contact_name,                      $output = '<span class="LC_warning">'.
                                              $contact_email,$captcha_error);                                &mt('Validation of the code you entered failed.').'</span>'.
                                 '<br />'.$captcha_error."\n".'<br /><p>'.
                                  &mt('[_1]Return[_2] to the previous page to try again.',
                                      '<a href="javascript:document.retryemail.submit();">','</a>')."\n".
                                 '<form name="retryemail" action="/adm/createaccount" method="post" />'.
                                 '<input type="hidden" name="domain" value="'.$domain.'" />'."\n";
                       if ($env{'form.courseid'} =~ /^$match_domain\_$match_courseid$/) {
                           $output .= '<input type="hidden" name="courseid" value="'.$env{'form.courseid'}.'" />'."\n";
                       }
                       if ($env{'form.type'}) {
                           my $usertype = &get_usertype($domain);
                           if ($usertype ne '') {
                               $output .= '<input type="hidden" name="type" value="'.$usertype.'" />'."\n".
                                          '<input type="hidden" name="reportedtype" value="'.&mt('Submit').'" />'."\n";
                           }
                       }
                       $output .= '</form></p>';
                     return $output;                      return $output;
                 }                  }
                 my (%rulematch,%inst_results,%curr_rules,%got_rules,%alerts);                  my (%rulematch,%inst_results,%curr_rules,%got_rules,%alerts);
Line 874  sub process_email_request { Line 901  sub process_email_request {
                               $contact_email,$courseid,$emailusername,$usertype,                                $contact_email,$courseid,$emailusername,$usertype,
                               $uname);                                $uname);
     }      }
     return $output;      return '<div class="LC_landmark" role="main">'.$output.'</div>';
 }  }
   
 sub call_rulecheck {  sub call_rulecheck {
Line 894  sub call_rulecheck { Line 921  sub call_rulecheck {
 sub send_token {  sub send_token {
     my ($domain,$email,$server,$domdesc,$contact_name,$contact_email,$courseid,$emailusername,      my ($domain,$email,$server,$domdesc,$contact_name,$contact_email,$courseid,$emailusername,
         $usertype,$uname) = @_;          $usertype,$uname) = @_;
     my $msg = '<h3>'.&mt('Account creation status').'</h3>'.      my $msg = '<h2 class="LC_heading_2">'.&mt('Account creation status').'</h2>'.
               &mt('Thank you for your request to create a new LON-CAPA account.').                &mt('Thank you for your request to create a new LON-CAPA account.').
               '<br /><br />';                '<br /><br />';
     my $now = time;      my $now = time;
     $env{'form.logtoken'} =~ s/(`)//g;      $env{'form.logtoken'} =~ s/(`)//g;
     if ($env{'form.logtoken'}) {      if ($env{'form.logtoken'}) {
         my $logtoken = $env{'form.logtoken'};          my $logtoken = $env{'form.logtoken'};
           my $earlyout;
         my $tmpinfo=Apache::lonnet::reply('tmpget:'.$logtoken,$server);          my $tmpinfo=Apache::lonnet::reply('tmpget:'.$logtoken,$server);
         if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) {          if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) {
             $msg = &mt('Information needed to process your request is missing, inaccessible or expired.')              $msg = &mt('Information needed to process your request is missing, inaccessible or expired.')
                   .'<br />'.&mt('Return to the previous page to try again.');                    .'<br /><p>'.&mt('[_1]Return[_2] to the previous page to try again.',
                                      '<a href="javascript:document.retryemail.submit();">','</a>');
               $earlyout = 1;
         } else {          } else {
             my $reply = &Apache::lonnet::reply('tmpdel:'.$logtoken,$server);              my $reply = &Apache::lonnet::reply('tmpdel:'.$logtoken,$server);
             unless ($reply eq 'ok') {              unless ($reply eq 'ok') {
                 $msg .= &mt('Request could not be processed.');                  $msg .= &mt('Request could not be processed.');
             }              }
         }          }
         my %info = ('ip'         => $ENV{'REMOTE_ADDR'},  # 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.').
                      '<br /><p>'.&mt('[_1]Return[_2] to the previous page to try again.',
                                      '<a href="javascript:document.retryemail.submit();">','</a>');
               $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.
                                  '<p>'.&mt('[_1]Return[_2] to the previous page to try again.',
                                            '<a href="javascript:document.retryemail.submit();">','</a>');
                           $earlyout = 1;
                       }
                   }
               }
           }
           if ($earlyout) {
               $msg .= '<form name="retryemail" action="/adm/createaccount" method="post" />'.
                       '<input type="hidden" name="domain" value="'.$domain.'" />'."\n";
               if ($env{'form.courseid'} =~ /^$match_domain\_$match_courseid$/) {
                   $msg .= '<input type="hidden" name="courseid" value="'.$env{'form.courseid'}.'" />'."\n";
               }
               if ($env{'form.type'}) {
                   my $usertype = &get_usertype($domain);
                   if ($usertype ne '') {
                       $msg .= '<input type="hidden" name="type" value="'.$usertype.'" />'.
                               '<input type="hidden" name="reportedtype" value="'.&mt('Submit').'" />'."\n";
                   }
               }
               $msg .= '</form></p>';
               return $msg;
           }
           my $ip = &Apache::lonnet::get_requestor_ip();
           my %info = ('ip'         => $ip,
                     'time'       => $now,                      'time'       => $now,
                     'domain'     => $domain,                      'domain'     => $domain,
                     'username'   => $email,                      'username'   => $email,
Line 1027  sub process_mailtoken { Line 1111  sub process_mailtoken {
                             &create_account($r,$domain,$domdesc,\%data);                              &create_account($r,$domain,$domdesc,\%data);
                         if ($result eq 'ok') {                          if ($result eq 'ok') {
                             $msg = $output;                              $msg = $output;
                               my $ip = &Apache::lonnet::get_requestor_ip();
                             my $shownow = &Apache::lonlocal::locallocaltime($now);                              my $shownow = &Apache::lonlocal::locallocaltime($now);
                             my $mailmsg = &mt('A LON-CAPA account for the institution: [_1] has been created [_2] from IP address: [_3]. If you did not perform this action or authorize it, please contact the [_4] ([_5]).',$domdesc,$shownow,$ENV{'REMOTE_ADDR'},$contact_name,$contact_email)."\n";                              my $mailmsg = &mt('A LON-CAPA account for the institution: [_1] has been created [_2] from IP address: [_3]. If you did not perform this action or authorize it, please contact the [_4] ([_5]).',$domdesc,$shownow,$ip,$contact_name,$contact_email)."\n";
                             my $mailresult = &Apache::resetpw::send_mail($domdesc,$data{'email'},                              my $mailresult = &Apache::resetpw::send_mail($domdesc,$data{'email'},
                                                                         $mailmsg,$contact_name,                                                                          $mailmsg,$contact_name,
                                                                         $contact_email);                                                                          $contact_email);
Line 1108  sub print_dataentry_form { Line 1193  sub print_dataentry_form {
         my ($lextkey,$uextkey) = &getkeys($lkey,$ukey);          my ($lextkey,$uextkey) = &getkeys($lkey,$ukey);
         my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount:createaccount',          my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount:createaccount',
                                            $lonhost);                                             $lonhost);
         $output .=          my $showsubmit = 1;
           my $serverform =
             '<form name="createaccount" method="post" target="_top" action="/adm/createaccount">';              '<form name="createaccount" method="post" target="_top" action="/adm/createaccount">';
         if ($courseid ne '') {          if ($courseid ne '') {
             $output .= '<input type="hidden" name="courseid" value="'.$courseid.'"/>'."\n";              $serverform .= '<input type="hidden" name="courseid" value="'.$courseid.'"/>'."\n";
         }          }
         if (ref($emailusername) eq 'HASH') {          if (ref($emailusername) eq 'HASH') {
             if (ref($emailusername->{$usertype}) eq 'HASH') {              if (ref($emailusername->{$usertype}) eq 'HASH') {
                 foreach my $field (sort(keys(%{$emailusername->{$usertype}}))) {                  foreach my $field (sort(keys(%{$emailusername->{$usertype}}))) {
                     $output .= '<input type="hidden" name="'.$field.'" value="" />'."\n";                      $serverform .= '<input type="hidden" name="'.$field.'" value="" />'."\n";
                 }                  }
             }              }
         }          }
         if ($captcha eq 'original') {          if ($captcha eq 'original') {
             $output .= '              $serverform .= '
    <input type="hidden" name="crypt" value="" />     <input type="hidden" name="crypt" value="" />
    <input type="hidden" name="code" value="" />     <input type="hidden" name="code" value="" />
 ';  ';
         } elsif ($captcha eq 'recaptcha') {          } elsif ($captcha eq 'recaptcha') {
             if ($recaptchaversion eq '2') {              if ($recaptchaversion eq '2') {
                 $output .= "$captchaform\n";                  $serverform .= &Apache::lonhtmlcommon::start_pick_box().
                                  &Apache::lonhtmlcommon::row_title(&mt('Validation').'<b>*</b>',
                                                                    'LC_pick_box_title',
                                                                    'LC_oddrow_value')."\n".
                                                                    $captchaform.
                                  &Apache::lonhtmlcommon::row_closure(1)."\n".
                                  &Apache::lonhtmlcommon::row_title()."\n".
                                  '<br /><input type="button" name="createaccount" value="'.
                                  &mt('Create account').'" onclick="checkpass('."'createaccount','newemail'".')" />'.
                                  &Apache::lonhtmlcommon::row_closure(1)."\n".
                                  &Apache::lonhtmlcommon::end_pick_box();
                 undef($captchaform);                  undef($captchaform);
                   undef($showsubmit);
             } else {              } else {
                 $output .= '                  $serverform .= '
    <input type="hidden" name="recaptcha_challenge_field" value="" />     <input type="hidden" name="recaptcha_challenge_field" value="" />
    <input type="hidden" name="recaptcha_response_field" value="" />     <input type="hidden" name="recaptcha_response_field" value="" />
 ';  ';
             }              }
         }          }
         if ($usertype ne '') {          if ($usertype ne '') {
             $output .= '<input type="hidden" name="type" value="'.              $serverform .= '<input type="hidden" name="type" value="'.
                        &HTML::Entities::encode($usertype,'\'<>"&').'" />'."\n";                             &HTML::Entities::encode($usertype,'\'<>"&').'" />'."\n";
         }          }
         if ($usernameset eq 'free') {          if ($usernameset eq 'free') {
             $output .= '<input type="hidden" name="username" value="" />'."\n";               $serverform .= '<input type="hidden" name="username" value="" />'."\n"; 
         }          }
         $output .= <<"ENDSERVERFORM";          $serverform .= <<"ENDSERVERFORM";
    <input type="hidden" name="logtoken" value="$logtoken" />     <input type="hidden" name="logtoken" value="$logtoken" />
    <input type="hidden" name="serverid" value="$lonhost" />     <input type="hidden" name="serverid" value="$lonhost" />
    <input type="hidden" name="uname" value="" />     <input type="hidden" name="uname" value="" />
Line 1155  sub print_dataentry_form { Line 1252  sub print_dataentry_form {
 ENDSERVERFORM  ENDSERVERFORM
         my $beginclientform = '<form name="newemail" method="post" action="" '.          my $beginclientform = '<form name="newemail" method="post" action="" '.
                               'onsubmit="return checkpass('."'createaccount','newemail'".');">'."\n";                                'onsubmit="return checkpass('."'createaccount','newemail'".');">'."\n";
         my $endclientform = '<input type="hidden" name="udom" value="'.$domain.'" />'."\n".          my $endclientform;
                             '<input type="hidden" name="lextkey" value="'.$lextkey.'" />'."\n".          unless ($showsubmit) {
                             '<input type="hidden" name="uextkey" value="'.$uextkey.'" />'."\n".              if ($usertype ne '') {
                             '</form>'."\n".                  $endclientform = '<input type="hidden" name="type" value="'.
                             '<p class="LC_info">'.&mt('Fields marked [_1]*[_2] are required.','<b>','</b>').'</p>';                                   &HTML::Entities::encode($usertype,'\'<>"&').'" />'."\n";
               }
           }
           $endclientform .= '<input type="hidden" name="udom" value="'.$domain.'" />'."\n".
                             '<input type="hidden" name="lextkey" value="'.$lextkey.'" />'."\n".
                             '<input type="hidden" name="uextkey" value="'.$uextkey.'" />'."\n".
                             '</form>'."\n";
         my ($datatable,$rowcount) =          my ($datatable,$rowcount) =
             &Apache::loncreateuser::personal_data_display('',$domain,'email','selfcreate',              &Apache::loncreateuser::personal_data_display('',$domain,'email','selfcreate',
                                                           '','',$now,$captchaform,                                                            '','','',$now,$captchaform,
                                                           $emailusername,$usertype,                                                            $emailusername,$usertype,
                                                           $usernameset,$condition,$excluded);                                                            $usernameset,$condition,$excluded,
                                                             $showsubmit);
         if ($rowcount) {          if ($rowcount) {
             $output .= '<div class="LC_left_float">'.$beginclientform.$datatable.$endclientform;              $output .= '<div class="LC_left_float">'.$beginclientform.$datatable.$endclientform.'</div>'."\n".
                          '<div class="LC_clear_float_footer"></div>'."\n";
         } else {          } else {
             $output .= $beginclientform.$endclientform;              $output .= $beginclientform.$endclientform;
         }          }
         if ($rowcount) {          $output .= $serverform.
             $output .= '</div>'."\n".                     '<p class="LC_info">'.
                        '<div class="LC_clear_float_footer"></div>'."\n";                     &mt('Fields marked [_1]*[_2] are required.','<b>','</b>').
         }                     '</p>';
     } else {      } else {
         $output = &mt('Could not load javascript file [_1]','<tt>londes.js</tt>');          $output = &mt('Could not load javascript file [_1]','<tt>londes.js</tt>');
     }      }
Line 1334  sub create_account { Line 1439  sub create_account {
             unless (($inststatus eq 'default') || ($inststatus eq '')) {              unless (($inststatus eq 'default') || ($inststatus eq '')) {
                 &Apache::lonnet::put('environment',{inststatus => $inststatus},$domain,$username);                  &Apache::lonnet::put('environment',{inststatus => $inststatus},$domain,$username);
             }              }
             $output .= '<br />'.&mt('Home server: [_1]',$uhome).' '.              $output .= '<br />'.&mt('Home Server').": $uhome ".
                        &Apache::lonnet::hostname($uhome).'<br /><br />';                         &Apache::lonnet::hostname($uhome).'<br /><br />';
             return ('ok',$output,$uhome);              return ('ok',$output,$uhome);
         } else {          } else {
Line 1444  sub login_failure_msg { Line 1549  sub login_failure_msg {
     } else {      } else {
         $url = "/adm/createaccount";          $url = "/adm/createaccount";
     }      }
     my $output = '<h4>'.&mt('Authentication failed').'</h4><div class="LC_warning">'.      my $output = '<h3 class="LC_heading_3">'.&mt('Authentication failed').'</h3><div class="LC_warning">'.
                  &mt('Username and/or password could not be authenticated.').                   &mt('Username and/or password could not be authenticated.').
                  '</div>'.                   '</div>'.
                  &mt('Please check the username and password.').'<br /><br />';                   &mt('Please check the username and password.').'<br /><br />';
Line 1507  sub username_check { Line 1612  sub username_check {
                     '<input type="hidden" name="udom" value="'.$domain.'" />'."\n".                      '<input type="hidden" name="udom" value="'.$domain.'" />'."\n".
                     '<input type="hidden" name="phase" value="username_activation" />';                      '<input type="hidden" name="phase" value="username_activation" />';
         my $now = time;          my $now = time;
         my %info = ('ip'         => $ENV{'REMOTE_ADDR'},          my $ip = &Apache::lonnet::get_requestor_ip();
           my %info = ('ip'         => $ip,
                     'time'       => $now,                      'time'       => $now,
                     'domain'     => $domain,                      'domain'     => $domain,
                     'username'   => $username);                      'username'   => $username);
Line 1522  sub username_check { Line 1628  sub username_check {
         }          }
     }      }
     if ($checkfail) {       if ($checkfail) { 
         $msg = '<br /><h4>'.&mt('Account creation unavailable').'</h4>';          $msg = '<br /><h3 class="LC_heading_3">'.&mt('Account creation unavailable').'</h3>';
         if ($checkfail eq 'username') {          if ($checkfail eq 'username') {
             $msg .= '<span class="LC_warning">'.              $msg .= '<span class="LC_warning">'.
                      &mt('A LON-CAPA account may not be created with the username you use.').                       &mt('A LON-CAPA account may not be created with the username you use.').
Line 1548  sub username_check { Line 1654  sub username_check {
         if ($rowcount) {          if ($rowcount) {
             if ($editable) {              if ($editable) {
                 if ($courseid ne '') {                   if ($courseid ne '') { 
                     $msg = '<br /><h4>'.&mt('User information').'</h4>';                      $msg = '<br /><h3 class="LC_heading_3">'.&mt('User information').'</h3>';
                 }                  }
                 $msg .= &mt('To create one, use the table below to provide information about yourself, then click the [_1]Create LON-CAPA account[_2] button.','<span class="LC_cusr_emph">','</span>').'<br />';                  $msg .= &mt('To create one, use the table below to provide information about yourself, then click the [_1]Create LON-CAPA account[_2] button.','<span class="LC_cusr_emph">','</span>').'<br />';
             } else {              } else {
                  if ($courseid ne '') {                   if ($courseid ne '') {
                      $msg = '<h4>'.&mt('Review user information').'</h4>';                       $msg = '<h3 class="LC_heading_3">'.&mt('Review user information').'</h3>';
                  }                   }
                  $msg .= &mt('A user account will be created with information displayed in the table below, when you click the [_1]Create LON-CAPA account[_2] button.','<span class="LC_cusr_emph">','</span>').'<br />';                   $msg .= &mt('A user account will be created with information displayed in the table below, when you click the [_1]Create LON-CAPA account[_2] button.','<span class="LC_cusr_emph">','</span>').'<br />';
             }              }
         } else {          } else {
             if ($courseid ne '') {              if ($courseid ne '') {
                 $msg = '<h4>'.&mt('Confirmation').'</h4>';                  $msg = '<h3 class="LC_heading_3">'.&mt('Confirmation').'</h3>';
             }              }
             $msg .= &mt('Confirm that you wish to create an account.');              $msg .= &mt('Confirm that you wish to create an account.');
         }          }
Line 1700  sub check_id { Line 1806  sub check_id {
   
 sub invalid_state {  sub invalid_state {
     my ($error,$domdesc,$contact_name,$contact_email,$msgtext) = @_;      my ($error,$domdesc,$contact_name,$contact_email,$msgtext) = @_;
     my $msg = '<h3>'.&mt('Account creation unavailable').'</h3><span class="LC_error">';      my $msg = '<h2 class="LC_heading_2">'.&mt('Account creation unavailable').'</h2><span class="LC_error">';
     if ($error eq 'baduseremail') {      if ($error eq 'baduseremail') {
         $msg .= &mt('The e-mail address you provided does not appear to be a valid address.');          $msg .= &mt('The e-mail address you provided does not appear to be a valid address.');
     } elsif ($error eq 'badusername') {      } elsif ($error eq 'badusername') {
Line 1711  sub invalid_state { Line 1817  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.');          $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') {      } elsif ($error eq 'userformat') {
         $msg .= &mt('The e-mail address you provided may not be used as a username at this LON-CAPA institution.');          $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') {      } 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.');          $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') {      } elsif ($error eq 'emailfail') {

Removed from v.1.77  
changed lines
  Added in v.1.90


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>