Diff for /loncom/auth/lonauth.pm between versions 1.101.8.7 and 1.101.8.9.2.1

version 1.101.8.7, 2011/09/27 20:18:45 version 1.101.8.9.2.1, 2012/02/06 03:27:59
Line 40  use Apache::lonmenu(); Line 40  use Apache::lonmenu();
 use Apache::createaccount;  use Apache::createaccount;
 use Fcntl qw(:flock);  use Fcntl qw(:flock);
 use Apache::lonlocal;  use Apache::lonlocal;
   use Apache::File();
 use HTML::Entities;  use HTML::Entities;
     
 # ------------------------------------------------------------ Successful login  # ------------------------------------------------------------ Successful login
Line 136  sub success { Line 137  sub success {
   
     my %lt=&Apache::lonlocal::texthash(      my %lt=&Apache::lonlocal::texthash(
        'wel' => 'Welcome',         'wel' => 'Welcome',
        'mes' => 'Welcome to the Learning<i>Online</i> Network with CAPA. Please wait while your session is being set up.',  
        'pro' => 'Login problems?',         'pro' => 'Login problems?',
        'log' => 'loginproblems.html',         'log' => 'loginproblems.html',
        );         );
       my $welcome = &mt('Welcome to the Learning[_1]Online[_2] Network with CAPA. Please wait while your session is being set up.','<i>','</i>');
     $r->print(<<ENDSUCCESS);      $r->print(<<ENDSUCCESS);
 $start_page  $start_page
 $setflags  $setflags
 $windowinfo  $windowinfo
 <h1>$lt{'wel'}</h1>  <h1>$lt{'wel'}</h1>
 $lt{'mes'}<p>  $welcome<p>
 <a href="/adm/$lt{'log'}">$lt{'pro'}</a></p>  <a href="/adm/$lt{'log'}">$lt{'pro'}</a></p>
 $remoteinfo  $remoteinfo
 $maincall  $maincall
Line 331  sub handler { Line 332  sub handler {
     }      }
   
 # ---------------------------------------------------------------- Authenticate  # ---------------------------------------------------------------- Authenticate
     my @cancreate;  
     my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$form{'udom'});      my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$form{'udom'});
     if (ref($domconfig{'usercreation'}) eq 'HASH') {      my ($cancreate,$statustocreate) =
         if (ref($domconfig{'usercreation'}{'cancreate'}) eq 'HASH') {          &Apache::createaccount::get_creation_controls($form{'udom'},$domconfig{'usercreation'});
             if (ref($domconfig{'usercreation'}{'cancreate'}{'selfcreate'}) eq 'ARRAY') {  
                 @cancreate = @{$domconfig{'usercreation'}{'cancreate'}{'selfcreate'}};  
             } elsif (($domconfig{'usercreation'}{'cancreate'}{'selfcreate'} ne 'none') &&   
                      ($domconfig{'usercreation'}{'cancreate'}{'selfcreate'} ne '')) {  
                 @cancreate = ($domconfig{'usercreation'}{'cancreate'}{'selfcreate'});  
             }  
         }  
     }  
     my $defaultauth;      my $defaultauth;
     if (grep(/^login$/,@cancreate)) {      if (ref($cancreate) eq 'ARRAY') {
         $defaultauth = 1;          if (grep(/^login$/,@{$cancreate})) {
               $defaultauth = 1;
           }
     }      }
     my $clientcancheckhost = 1;      my $clientcancheckhost = 1;
     my $authhost=Apache::lonnet::authenticate($form{'uname'},$upass,      my $uname = $form{'uname'};
       my $authhost=Apache::lonnet::authenticate($uname,$upass,
                                               $form{'udom'},$defaultauth,                                                $form{'udom'},$defaultauth,
                                               $clientcancheckhost);                                                $clientcancheckhost);
           
 # --------------------------------------------------------------------- Failed?  # --------------------------------------------------------------------- Failed?
   
     if ($authhost eq 'no_host') {      if ($authhost eq 'no_host') {
  &failed($r,'Username and/or password could not be authenticated.',          my $lc_uname = lc($uname);
  \%form);          if ($uname eq $lc_uname) {
         return OK;              &failed($r,'Username and/or password could not be authenticated.',
     } elsif ($authhost eq 'no_account_on_host') {                      \%form);
         my %domconfig =   
             &Apache::lonnet::get_dom('configuration',['usercreation'],$form{'udom'});  
         if (grep(/^login$/,@cancreate)) {  
             my $domdesc = &Apache::lonnet::domain($form{'udom'},'description');  
             unless (&check_can_host($r,\%form,'no_account_on_host',$domdesc)) {  
                 return OK;       
             }  
             my $start_page =   
                 &Apache::loncommon::start_page('Create a user account in LON-CAPA',  
                                                '',{'no_inline_link'   => 1,});  
             my $lonhost = $r->dir_config('lonHostID');  
             my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};  
             my $contacts =   
                 &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',  
                                                         $form{'udom'},$origmail);  
             my ($contact_email) = split(',',$contacts);   
             my $output = &Apache::createaccount::username_check($form{'uname'},   
                                                                 $form{'udom'},$domdesc,'',  
                                                                 $lonhost,$contact_email,$contact_name);  
             &Apache::loncommon::content_type($r,'text/html');  
             $r->send_http_header;  
             &Apache::createaccount::print_header($r,$start_page);  
             $r->print('<h3>'.&mt('Account creation').'</h3>'.  
                       &mt('Although your username and password were authenticated, you do not currently have a LON-CAPA account at this institution.').'<br />'.  
                       $output.&Apache::loncommon::end_page());  
             return OK;              return OK;
         } else {          } else {
             &failed($r,'Although your username and password were authenticated, you do not currently have a LON-CAPA account in this domain, and you are not permitted to create one.',\%form);              $authhost=Apache::lonnet::authenticate($lc_uname,$upass,
             return OK;                                                     $form{'udom'},$defaultauth);
               if ($authhost eq 'no_host') {
                   &failed($r,'Username (in lower case) and/or password could not be authenticated.',
                           \%form);
                   return OK;
               } elsif ($authhost eq 'no_account_on_host') {
                   &create_account($r,\%form,\@cancreate,$lc_uname,$contact_name);
                   return OK;
               } else {
                   $form{'uname'} = $lc_uname;
               }
         }          }
       } elsif ($authhost eq 'no_account_on_host') {
           &create_account($r,\%form,\@cancreate,$uname,$contact_name);
           return OK;
     }      }
   
     if (($firsturl eq '') ||       if (($firsturl eq '') || 
Line 548  sub noswitch { Line 532  sub noswitch {
     return $result;      return $result;
 }  }
   
   sub create_account {
       my ($r,$form,$cancreate,$uname,$contact_name) = @_;
       return unless((ref($form) eq 'HASH') && (ref($cancreate) eq 'ARRAY'));
       my %domconfig =
           &Apache::lonnet::get_dom('configuration',['usercreation'],$form->{'udom'});
       if (&check_can_host($r,\%form,'no_account_on_host',$domdesc)) {
           my $start_page =
               &Apache::loncommon::start_page('Create a user account in LON-CAPA',
                                              '',{'no_inline_link'   => 1,});
           my $domdesc = &Apache::lonnet::domain($form->{'udom'},'description');
           my $lonhost = $r->dir_config('lonHostID');
           my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
           my $contacts =
               &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
                                                       $form->{'udom'},$origmail);
           my ($contact_email) = split(',',$contacts);
           my $output =
               &Apache::createaccount::username_check($uname,$form->{'udom'},
                                                      $domdesc,'',$lonhost,
                                                      $contact_email,$contact_name);
           &Apache::loncommon::content_type($r,'text/html');
           $r->send_http_header;
           &Apache::createaccount::print_header($r,$start_page);
           $r->print('<h3>'.&mt('Account creation').'</h3>'.
                     &mt('Although your username and password were authenticated, you do not currently have a LON-CAPA account at this institution.').'<br />'.
                     $output.&Apache::loncommon::end_page());
       } else {
           &failed($r,'Although your username and password were authenticated, you do not currently have a LON-CAPA account in this domain, and you are not permitted to create one.',$form);
       }
       return;
   }
   
 1;  1;
 __END__  __END__
   

Removed from v.1.101.8.7  
changed lines
  Added in v.1.101.8.9.2.1


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