Diff for /loncom/auth/lonauth.pm between versions 1.57 and 1.63

version 1.57, 2003/09/20 17:44:22 version 1.63, 2004/10/28 16:25:19
Line 181  sub success { Line 181  sub success {
 # -------------------------------------------------------- Menu script and info  # -------------------------------------------------------- Menu script and info
     my $windowinfo=&Apache::lonmenu::open($clientos);      my $windowinfo=&Apache::lonmenu::open($clientos);
     my $startupremote=&Apache::lonmenu::startupremote($lowerurl);      my $startupremote=&Apache::lonmenu::startupremote($lowerurl);
       my $remoteinfo=&Apache::lonmenu::load_remote_msg($lowerurl);
     my $setflags=&Apache::lonmenu::setflags();      my $setflags=&Apache::lonmenu::setflags();
     my $maincall=&Apache::lonmenu::maincall();      my $maincall=&Apache::lonmenu::maincall();
     my $bodytag=&Apache::loncommon::bodytag('Successful Login');      my $bodytag=&Apache::loncommon::bodytag('Successful Login');
       my $add=&addcontent();
 # ------------------------------------------------- Output for successful login  # ------------------------------------------------- Output for successful login
   
     $r->send_cgi_header(<<ENDHEADER);      $r->send_cgi_header(<<ENDHEADER);
 Content-type: text/html  Content-type: text/html$add
 Set-cookie: $cookie  Set-cookie: $cookie
   
 ENDHEADER  ENDHEADER
       my %lt=&Apache::lonlocal::texthash(
          'wel' => 'Welcome',
          'mes' => 'Welcome to the Learning<i>Online</i> Network with CAPA. Please wait while your session is being set up',
          'pro' => 'Problems',
          'log' => 'loginproblems.html',
          );
     $r->print(<<ENDSUCCESS);      $r->print(<<ENDSUCCESS);
 <html>  <html>
 <head>  <head>
Line 200  $startupremote Line 208  $startupremote
 $bodytag  $bodytag
 $setflags  $setflags
 $windowinfo  $windowinfo
 <h1>Welcome!</h1>  <h1>$lt{'wel'}</h1>
 Welcome to the Learning<i>Online</i> Network with CAPA.  $lt{'mes'}.<p>
 Please wait while your session  <a href="/adm/$lt{'log'}">$lt{'pro'}?</a></p>
 is being set up.<p>  $remoteinfo
 <a href="/adm/loginproblems.html">Problems?</a></p>  
 $maincall  $maincall
 </body>  </body>
 </html>  </html>
Line 216  ENDSUCCESS Line 223  ENDSUCCESS
 sub failed {  sub failed {
     my ($r,$message) = @_;      my ($r,$message) = @_;
     my $bodytag=&Apache::loncommon::bodytag('Unsuccessful Login');      my $bodytag=&Apache::loncommon::bodytag('Unsuccessful Login');
       my $add=&addcontent();
     $r->send_cgi_header(<<ENDFHEADER);      $r->send_cgi_header(<<ENDFHEADER);
 Content-type: text/html  Content-type: text/html$add
   
 ENDFHEADER  ENDFHEADER
     $r->print(<<ENDFAILED);      $r->print(<<ENDFAILED);
Line 225  ENDFHEADER Line 233  ENDFHEADER
 <head>  <head>
 <title>Unsuccessful Login to the LearningOnline Network with CAPA</title>  <title>Unsuccessful Login to the LearningOnline Network with CAPA</title>
 </head>  </head>
 <html>  
 $bodytag  $bodytag
 <h1>Sorry ...</h1>  <h1>Sorry ...</h1>
 <p><b>$message</b></p>  <p><b>$message</b></p>
Line 237  $bodytag Line 244  $bodytag
 ENDFAILED  ENDFAILED
 }  }
   
   # --------------------------------------------------------------------- Charset
   
   sub addcontent {
       my $encoding=&Apache::lonlocal::current_encoding;
       if ($encoding) {
    return '; charset='.$encoding;
       } else {
    return '';
       }
   }
   
 # ------------------------------------------------------------------ Rerouting!  # ------------------------------------------------------------------ Rerouting!
   
 sub reroute {  sub reroute {
Line 251  ENDRFHEADER Line 269  ENDRFHEADER
 <head>  <head>
 <title>Rerouting Login to the LearningOnline Network with CAPA</title>  <title>Rerouting Login to the LearningOnline Network with CAPA</title>
 </head>  </head>
 <html>  
 $bodytag  $bodytag
 <h1>Sorry ...</h1>  <h1>Sorry ...</h1>
 Please <a href="/">log in again</a>.  Please <a href="/">log in again</a>.
Line 273  sub handler { Line 290  sub handler {
   
     &Apache::lonlocal::get_language_handle($r);      &Apache::lonlocal::get_language_handle($r);
   
   # -------------------------------- Prevent users from attempting to login twice
       my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
       my $lonid=$cookies{'lonID'};
       my $cookie;
       if ($lonid) {
    my $handle=$lonid->value;
           $handle=~s/\W//g;
           my $lonidsdir=$r->dir_config('lonIDsDir');
           if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) {
   # Indeed, a valid token is found
       $r->send_cgi_header(<<ENDFHEADER);
   Content-type: text/html
   
   ENDFHEADER
       my $bodytag=&Apache::loncommon::bodytag('Already logged in');
       $r->print(<<ENDFAILED);
   <html>
   <head>
   <title>Already logged in</title>
   </head>
   $bodytag
   <h1>You are already logged in</h1>
   <p>Please either <a href="/adm/roles">continue the current session</a> or
   <a href="/adm/logout">logout</a>.</p>
   <p>
   <a href="/adm/loginproblems.html">Problems?</a></p>
   </body>
   </html>
   ENDFAILED
              return OK;
    }
       }
   
   # ---------------------------------------------------- No valid token, continue
   
   
     my $buffer;      my $buffer;
     $r->read($buffer,$r->header_in('Content-length'),0);      $r->read($buffer,$r->header_in('Content-length'),0);
     my @pairs=split(/&/,$buffer);      my @pairs=split(/&/,$buffer);
Line 290  sub handler { Line 343  sub handler {
  failed($r,'Username, password and domain need to be specified.');   failed($r,'Username, password and domain need to be specified.');
         return OK;          return OK;
     }      }
   
   # split user logging in and "su"-user
   
       ($FORM{'uname'},$FORM{'suname'})=split(/\:/,$FORM{'uname'});
     $FORM{'uname'} =~ s/\W//g;      $FORM{'uname'} =~ s/\W//g;
       $FORM{'suname'} =~ s/\W//g;
     $FORM{'udom'}  =~ s/\W//g;      $FORM{'udom'}  =~ s/\W//g;
   
     my $role   = $r->dir_config('lonRole');      my $role   = $r->dir_config('lonRole');
Line 343  sub handler { Line 401  sub handler {
         return OK;          return OK;
     }      }
   
     if (($firsturl eq '') || ($firsturl eq '/adm/logout')) {      if (($firsturl eq '') || 
    ($firsturl=~/^\/adm\/(logout|remote)/)) {
  $firsturl='/adm/roles';   $firsturl='/adm/roles';
     }      }
   # --------------------------------- Are we attempting to login as somebody else?
     success($r,$FORM{'uname'},$FORM{'udom'},$authhost,$firsturl);      if ($FORM{'suname'}) {
   # ------------ see if the original user has enough privileges to pull this stunt
    if (&Apache::lonnet::privileged($FORM{'uname'},$FORM{'udom'})) {
   # ---------------------------------------------------- see if the su-user exists
       unless (&Apache::lonnet::homeserver($FORM{'suname'},$FORM{'udom'})
    eq 'no_host') {
    &Apache::lonnet::logthis(&Apache::lonnet::homeserver($FORM{'suname'},$FORM{'udom'}));
   # ------------------------------ see if the su-user is not too highly privileged
    unless (&Apache::lonnet::privileged($FORM{'suname'},$FORM{'udom'})) {
   # -------------------------------------------------------- actually switch users
       &Apache::lonnet::logperm('User '.$FORM{'uname'}.' at '.$FORM{'udom'}.
    ' logging in as '.$FORM{'suname'});
       $FORM{'uname'}=$FORM{'suname'};
    } else {
       &Apache::lonnet::logthis('Attempted switch user to privileged user');
    }
       }
    } else {
       &Apache::lonnet::logthis('Non-privileged user attempting switch user');
    }
       }
       &success($r,$FORM{'uname'},$FORM{'udom'},$authhost,$firsturl);
     return OK;      return OK;
 }  }
   

Removed from v.1.57  
changed lines
  Added in v.1.63


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