version 1.32, 2013/09/29 00:49:24
|
version 1.35, 2016/12/16 15:31:11
|
Line 96 sub handler {
|
Line 96 sub handler {
|
|
|
if (!defined($switch_to)) { return FORBIDDEN; } |
if (!defined($switch_to)) { return FORBIDDEN; } |
|
|
|
my $protocol = 'http'; |
|
if ($env{'form.otherserver'}) { |
|
if ($Apache::lonnet::protocol{$env{'form.otherserver'}} eq 'https') { |
|
$protocol = $Apache::lonnet::protocol{$env{'form.otherserver'}}; |
|
} |
|
} |
|
|
if ($env{'user.name'} eq 'public' |
if ($env{'user.name'} eq 'public' |
&& $env{'user.domain'} eq 'public') { |
&& $env{'user.domain'} eq 'public') { |
my $url = 'http://'.$switch_to.$r->uri; |
my $url = $protocol.'://'.$switch_to.$r->uri; |
return &do_redirect($r,$url,1) |
return &do_redirect($r,$url,1) |
} |
} |
|
|
my $skip_canhost_check = ''; |
my $skip_canhost_check = ''; |
if ($env{'form.role'}) { |
if ($env{'form.role'}) { |
if (!exists($env{'user.role.'.$env{'form.role'}})) { |
if (!exists($env{'user.role.'.$env{'form.role'}})) { |
return FORBIDDEN; |
delete($env{'form.role'}); |
} else { |
} else { |
my $now = time; |
my $now = time; |
my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.role'}}); |
my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.role'}}); |
if (($start && $start > $now) || ($end && $end < $now)) { |
if (($start && $start > $now) || ($end && $end < $now)) { |
return FORBIDDEN; |
delete($env{'form.role'}); |
} elsif ($env{'form.role'} eq 'au./'.$env{'user.domain'}.'/') { |
} elsif ($env{'form.role'} eq 'au./'.$env{'user.domain'}.'/') { |
if (&Apache::lonnet::homeserver($env{'user.name'},$env{'user.domain'}) eq $env{'form.otherserver'}) { |
if (&Apache::lonnet::homeserver($env{'user.name'},$env{'user.domain'}) eq $env{'form.otherserver'}) { |
$skip_canhost_check = 1; |
$skip_canhost_check = 1; |
Line 153 sub handler {
|
Line 160 sub handler {
|
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); |
|
my $logmsg = "Switch Server to $env{'form.otherserver'}"; |
|
if ($env{'form.role'}) { |
|
$logmsg .= " with role: $env{'form.role'}"; |
|
} else { |
|
$logmsg .= " (no role)"; |
|
} |
|
$logmsg .= ' '.$ENV{'REMOTE_ADDR'}; |
&Apache::lonnet::log($env{'user.domain'},$env{'user.name'}, |
&Apache::lonnet::log($env{'user.domain'},$env{'user.name'}, |
$env{'user.home'}, |
$env{'user.home'},$logmsg); |
"Switch Server to $env{'form.otherserver'} with role $env{'form.role'} $ENV{'REMOTE_ADDR'}"); |
|
|
|
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
|
|
Line 193 sub handler {
|
Line 206 sub handler {
|
$info{'sso.reloginserver'} = $env{'request.sso.reloginserver'}; |
$info{'sso.reloginserver'} = $env{'request.sso.reloginserver'}; |
} |
} |
my $token = &Apache::lonnet::tmpput(\%info,$env{'form.otherserver'}); |
my $token = &Apache::lonnet::tmpput(\%info,$env{'form.otherserver'}); |
my $url ='http://'.$switch_to.'/adm/login?'. |
my $url =$protocol.'://'.$switch_to.'/adm/login?'. |
'domain='.$env{'user.domain'}. |
'domain='.$env{'user.domain'}. |
'&username='.$env{'user.name'}. |
'&username='.$env{'user.name'}. |
'&token='.$token; |
'&token='.$token; |