Diff for /loncom/auth/lonauth.pm between versions 1.3 and 1.4

version 1.3, 1999/12/16 20:30:55 version 1.4, 2000/01/14 21:12:40
Line 1 Line 1
 # The LearningOnline Network  # The LearningOnline Network
 # User Authentication Module  # User Authentication Module
 # 5/21/99,5/22,5/25,5/26,5/27,5/29,6/2,6/11,6/14,6/15  # 5/21/99,5/22,5/25,5/26,5/27,5/29,6/2,6/11,6/14,6/15
 # 16/11,12/16 Gerd Kortemeyer  # 16/11,12/16,
   # 1/14 Gerd Kortemeyer
   
 package Apache::lonauth;  package Apache::lonauth;
   
Line 14  use Apache::lonnet(); Line 15  use Apache::lonnet();
 # ------------------------------------------------------------ Successful login  # ------------------------------------------------------------ Successful login
   
 sub success {  sub success {
     my ($r, $lowerurl, $username, $domain, $authhost) = @_;      my ($r, $username, $domain, $authhost) = @_;
     my $lonids=$r->dir_config('lonIDsDir');      my $lonids=$r->dir_config('lonIDsDir');
 # See if old ID present, but overlooked  
   # See if old ID present, if so, remove
     my $cookie;      my $cookie;
     if ($cookie=<$lonids/$username\_*\_$domain\_$authhost.id>) {      while ($cookie=<$lonids/$username\_*\_$domain\_$authhost.id>) {
  $cookie=~s/\.id//;   unlink($cookie);
         $cookie=~s/$lonids\///;      }
     } else {  
   # Give them a new cookie
   
         my $now=time;          my $now=time;
         $cookie="$username\_$now\_$domain\_$authhost";          $cookie="$username\_$now\_$domain\_$authhost";
         my $userroles=Apache::lonnet::reply(          my $rolesdump=Apache::lonnet::reply("dump:$domain:$username:roles",
     "dump:$domain:$username:roles",  
                                             $authhost);                                              $authhost);
         $userroles=~s/&/\n/g;          my $userroles='';
           if ($rolesdump ne '') {
               map {
                  my ($area,$role)=split(/=/,$_);
                  my ($trole,$tend,$tstart)=split(/_/,$role);
                  if ($tend!=0) {
      if ($tend<$now) {
          my $localtime=localtime($tend);
                          $trole="Role expired $localtime";
                      } 
                  }
                  if ($tstart!=0) {
                      if ($tstart>$now) {
                         my $localtime=localtime($tend);
                         $trole="Role becomes active $localtime";        
                      }
                  }
                  if ($area ne '') {
      $userroles.="user.role.$area=$trole\n";
                  }
               } split(/&/,$rolesdump);            
           }  
         {          {
     my $idf=Apache::File->new(">$lonids/$cookie.id");      my $idf=Apache::File->new(">$lonids/$cookie.id");
             print $idf "username=$username\n";              print $idf "user.name=$username\n";
             print $idf "userdomain=$domain\n";              print $idf "user.domain=$domain\n";
             print $idf "userhome=$authhost\n";              print $idf "user.home=$authhost\n";
             print $idf "$userroles\n";              if ($userroles ne '') { print $idf "$userroles" };
         }          }
     }  
     $cookie="lonID=$cookie; path=/";      $cookie="lonID=$cookie; path=/";
     $r->send_cgi_header(<<ENDHEADER);      $r->send_cgi_header(<<ENDHEADER);
 Content-type: text/html  Content-type: text/html
Line 45  ENDHEADER Line 69  ENDHEADER
     $r->print(<<ENDSUCCESS);      $r->print(<<ENDSUCCESS);
 <html>  <html>
 <head>  <head>
 <title>Successful Login to the LearningOnline Network</title>  <title>Successful Login to the LearningOnline Network with CAPA</title>
 </head>  </head>
 <frameset rows="80,*" border=0>  <frameset rows="80,*" border=0>
 <frame scrolling="no" name="loncontrol" src="/adm/menu">  <frame scrolling="no" name="loncontrol" src="/adm/menu">
 <frame name="loncontent" src="$lowerurl">  <frame name="loncontent" src="/adm/roles">
 </frameset>  </frameset>
 </html>  </html>
 ENDSUCCESS  ENDSUCCESS
Line 66  ENDFHEADER Line 90  ENDFHEADER
     $r->print(<<ENDFAILED);      $r->print(<<ENDFAILED);
 <html>  <html>
 <head>  <head>
 <title>Unsuccessful Login to the LearningOnline Network</title>  <title>Unsuccessful Login to the LearningOnline Network with CAPA</title>
 </head>  </head>
 <html>  <html>
 <body bgcolor="#FFFFFF">  <body bgcolor="#FFFFFF">
 <h1>Sorry ...</h1>  <h1>Sorry ...</h1>
 <h2>$message to use the Learning<i>Online</i> Network</h2>  <h2>$message to use the Learning<i>Online</i> Network with CAPA</h2>
 </body>  </body>
 </html>  </html>
 ENDFAILED  ENDFAILED
Line 120  sub handler { Line 144  sub handler {
     if (!$lonurl) { failed($r,'Cookies need to be activated'); return OK; }      if (!$lonurl) { failed($r,'Cookies need to be activated'); return OK; }
     my $lowerurl=$lonurl->value;      my $lowerurl=$lonurl->value;
   
     success($r,$lowerurl,$FORM{'uname'},$FORM{'udom'},$authhost);      success($r,$FORM{'uname'},$FORM{'udom'},$authhost);
     return OK;      return OK;
 }  }
   

Removed from v.1.3  
changed lines
  Added in v.1.4


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