version 1.1, 2005/10/24 21:32:42
|
version 1.4, 2005/12/28 19:26:02
|
Line 26
|
Line 26
|
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
# |
|
|
package Apache::startuser; |
package Apache::migrateuser; |
|
|
use strict; |
use strict; |
use Apache::Constants qw(:common :http :methods); |
use Apache::Constants qw(:common :http :methods); |
Line 34 use Apache::lonauth;
|
Line 34 use Apache::lonauth;
|
use Apache::lonnet; |
use Apache::lonnet; |
|
|
sub goto_login { |
sub goto_login { |
my ($r) = @_; |
my ($r) = @_; |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
$r->print(<<TOLOGIN); |
$r->print(<<TOLOGIN); |
<html> |
<html> |
<head> |
<head> |
<meta http-equiv="refresh" content="10;url=/adm/login" /> |
<meta http-equiv="refresh" content="0;url=/adm/login" /> |
<title>Going to login</title> |
<title>Going to login</title> |
</head> |
</head> |
<body> |
<body> |
Line 52 sub goto_login {
|
Line 52 sub goto_login {
|
</body> |
</body> |
</html> |
</html> |
TOLOGIN |
TOLOGIN |
return ''; |
return OK; |
} |
} |
|
|
|
|
sub handler { |
sub handler { |
my ($r) = @_; |
my ($r) = @_; |
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['token']); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['token']); |
my $data = &Apache::lonnet::reply('tmpget:'.$env{'form.token'}, |
my %data = &Apache::lonnet::tmpget($env{'form.token'}); |
$Apache::lonnet::perlvar{'lonHostID'}); |
my $delete = &Apache::lonnet::tmpdel($env{'form.token'}); |
my ($ip,$udom,$uname,$role) = split('&',$data); |
|
|
if ($delete ne 'ok') { |
if ($ip ne $ENV{'REMOTE_ADDR'} && $ip ne '127.0.0.1') { |
return &goto_login($r); |
#error or invalid token |
|
&goto_login($r); |
|
return OK; |
|
} |
} |
|
|
&Apache::lonnet::logthis("Allowing access for $uname\@$udom to $role"); |
if ($data{'ip'} ne $ENV{'REMOTE_ADDR'} || !defined($data{'username'}) || |
my $home=&Apache::lonnet::homeserver($uname,$udom); |
!defined($data{'domain'}) ) { |
my $cookie=&Apache::lonauth::success($r,$uname,$udom,$home,'noredirect'); |
return &goto_login($r); |
|
} |
|
|
|
&Apache::lonnet::logthis("Allowing access for $data{'username'}\@$data{'domain'} to $data{'role'}"); |
|
my $home=&Apache::lonnet::homeserver($data{'username'},$data{'domain'}); |
|
if ($home =~ /(con_lost|no_such_host)/) { return &goto_login($r); } |
|
|
|
if (!$data{'role'}) { |
|
&Apache::lonauth::success($r,$data{'username'},$data{'domain'}, |
|
$home,'/adm/roles'); |
|
return OK; |
|
} |
|
|
|
my $cookie=&Apache::lonauth::success($r,$data{'username'},$data{'domain'}, |
|
$home,'noredirect'); |
$r->header_out('Set-cookie',"lonID=$cookie; path=/"); |
$r->header_out('Set-cookie',"lonID=$cookie; path=/"); |
&Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'), |
&Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'), |
$cookie); |
$cookie); |
$env{'form.selectrole'}='1'; |
$env{'form.selectrole'}='1'; |
$env{'form.'.$role}='1'; |
$env{'form.'.$data{'role'}}='1'; |
return &Apache::lonroles::handler($r); |
return &Apache::lonroles::handler($r); |
} |
} |
|
|