Diff for /loncom/auth/switchserver.pm between versions 1.4 and 1.6

version 1.4, 2005/10/28 21:51:43 version 1.6, 2005/12/28 16:46:47
Line 37  use Apache::lonlocal; Line 37  use Apache::lonlocal;
   
 sub init_env {  sub init_env {
     my ($r) = @_;      my ($r) = @_;
       
       if (-e $env{'user.environment'}) {
    return  $env{'user.environment'};
       }
     my $requrl=$r->uri;      my $requrl=$r->uri;
     my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));      my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
     my $lonid=$cookies{'lonID'};      my $lonid=$cookies{'lonID'};
Line 53  sub init_env { Line 57  sub init_env {
   
     &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);      &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
           
     return $handle;      return $r->dir_config('lonIDsDir')."/$handle.id";
 }  }
   
 sub handler {  sub handler {
     my $r = shift;      my ($r) = @_;
       
           
     my $handle=&init_env($r);      my $handle=&init_env($r);
     if (!defined($handle)) { return FORBIDDEN; }      if (!defined($handle)) { return FORBIDDEN; }
   
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
     ['otherserver','role']);      ['otherserver','role']);
      
     my $switch_to=$Apache::lonnet::hostname{$env{'form.otherserver'}};      my $switch_to=$Apache::lonnet::hostname{$env{'form.otherserver'}};
     if (!$env{'form.otherserver'}) {      if (!$env{'form.otherserver'}) {
  $env{'form.otherserver'}=&Apache::lonnet::spareserver(30000,undef,1);   $env{'form.otherserver'}=&Apache::lonnet::spareserver(30000,undef,1);
  $switch_to=$Apache::lonnet::hostname{$env{'form.otherserver'}};   $switch_to=$Apache::lonnet::hostname{$env{'form.otherserver'}};
     }      }
   
     if (!defined($switch_to)) { return FORBIDDEN; }      if (!defined($switch_to)) { return FORBIDDEN; }
   
     if ($env{'form.role'} &&       if ($env{'form.role'} && 
  !exists($env{'user.role.'.$env{'form.role'}})) { return FORBIDDEN; }   !exists($env{'user.role.'.$env{'form.role'}})) { return FORBIDDEN; }
   
     #remove session env, and log event      #remove session env, and log event
     unlink($r->dir_config('lonIDsDir')."/$handle.id");      unlink($handle);
     my %temp=('switchserver' => time.':'.$env{'form.otherserver'},      my %temp=('switchserver' => time.':'.$env{'form.otherserver'},
       $env{'form.role'});        $env{'form.role'});
     &Apache::lonnet::put('email_status',\%temp);      &Apache::lonnet::put('email_status',\%temp);
Line 100  sub handler { Line 104  sub handler {
       'role'     => $env{'form.role'},        'role'     => $env{'form.role'},
       'server'   => $r->dir_config('lonHostID'));        'server'   => $r->dir_config('lonHostID'));
     my $token = &Apache::lonnet::tmpput(\%info,$env{'form.otherserver'});      my $token = &Apache::lonnet::tmpput(\%info,$env{'form.otherserver'});
     my $switch='<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url=http://'.$switch_to.'/adm/migrateuser?token='.$token.'">';      my $switch='<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url=http://'.$switch_to.'/adm/login?domain='.$env{'user.domain'}.'&username='.$env{'user.name'}.'&token='.$token.'">';
     my $bodytag=&Apache::loncommon::bodytag('Switching Server ...');      my $bodytag=&Apache::loncommon::bodytag('Switching Server ...');
 # --------------------------------------------------------------- Screen Output  # --------------------------------------------------------------- Screen Output
     $r->print(<<ENDDOCUMENT);      $r->print(<<ENDDOCUMENT);

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


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