version 1.3, 2005/10/28 21:51:43
|
version 1.11, 2007/09/29 02:09:50
|
Line 29
|
Line 29
|
package Apache::migrateuser; |
package Apache::migrateuser; |
|
|
use strict; |
use strict; |
|
use LONCAPA; |
use Apache::Constants qw(:common :http :methods); |
use Apache::Constants qw(:common :http :methods); |
use Apache::lonauth; |
use Apache::lonauth; |
use Apache::lonnet; |
use Apache::lonnet; |
|
use Apache::lonlocal; |
|
|
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(&Apache::loncommon::start_page('Going to login',undef, |
<html> |
{'redirect' => |
<head> |
[0,'/adm/login'],}). |
<meta http-equiv="refresh" content="0;url=/adm/login" /> |
'<h1>'.&mt('One moment please...').'</h1>'. |
<title>Going to login</title> |
'<p>'.&mt('Transferring to login page.').'</p>'. |
</head> |
&Apache::loncommon::end_page()); |
<body> |
|
<h1>One moment please...</h1> |
|
<p> |
|
Transferring to login page. |
|
<a href="/adm/login">Continue</a> |
|
</p> |
|
</body> |
|
</html> |
|
TOLOGIN |
|
return OK; |
return OK; |
} |
} |
|
|
|
|
|
sub sso_check { |
|
my ($data) = @_; |
|
my %extra_env; |
|
if ($data->{'sso.login'}) { |
|
$extra_env{'request.sso.login'} = $data->{'sso.login'}; |
|
} |
|
if ($data->{'sso.reloginserver'}) { |
|
$extra_env{'request.sso.reloginserver'} = |
|
$data->{'sso.reloginserver'}; |
|
} |
|
return \%extra_env; |
|
} |
|
|
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::tmpget($env{'form.token'}); |
my %data = &Apache::lonnet::tmpget($env{'form.token'}); |
|
my $delete = &Apache::lonnet::tmpdel($env{'form.token'}); |
|
|
|
&Apache::lonlocal::get_language_handle($r); |
|
|
|
if ($delete ne 'ok') { |
|
return &goto_login($r); |
|
} |
|
|
if ($data{'ip'} ne $ENV{'REMOTE_ADDR'} || !defined($data{'username'}) || |
if ($data{'ip'} ne $ENV{'REMOTE_ADDR'} || !defined($data{'username'}) || |
!defined($data{'domain'}) ) { |
!defined($data{'domain'}) ) { |
Line 71 sub handler {
|
Line 84 sub handler {
|
my $home=&Apache::lonnet::homeserver($data{'username'},$data{'domain'}); |
my $home=&Apache::lonnet::homeserver($data{'username'},$data{'domain'}); |
if ($home =~ /(con_lost|no_such_host)/) { return &goto_login($r); } |
if ($home =~ /(con_lost|no_such_host)/) { return &goto_login($r); } |
|
|
|
my $extra_env = &sso_check(\%data); |
|
|
if (!$data{'role'}) { |
if (!$data{'role'}) { |
&Apache::lonauth::success($r,$data{'username'},$data{'domain'}, |
# check for exisiting valid session |
$home,'/adm/roles'); |
my %cookies=CGI::Cookie->parse($r->header_in('Cookie')); |
|
my $lonid=$cookies{'lonID'}; |
|
my $handle; |
|
if ($lonid) { |
|
$handle=&LONCAPA::clean_handle($lonid->value); |
|
} |
|
if ($lonid |
|
&& -e $r->dir_config('lonIDsDir').'/'.$handle.'.id' |
|
&& $handle ne '') { |
|
&Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'), |
|
$handle); |
|
if ($env{'request.course.id'}) { |
|
$r->internal_redirect('/adm/navmaps'); |
|
} else { |
|
$r->internal_redirect('/adm/roles'); |
|
} |
|
} else { |
|
&Apache::lonauth::success($r,$data{'username'},$data{'domain'}, |
|
$home,'/adm/roles',$extra_env); |
|
|
|
} |
return OK; |
return OK; |
|
|
} |
} |
|
|
|
my $next_url='/adm/roles?selectrole=1&'.&escape($data{'role'}).'=1'; |
|
|
|
|
my $cookie=&Apache::lonauth::success($r,$data{'username'},$data{'domain'}, |
&Apache::lonauth::success($r,$data{'username'},$data{'domain'},$home, |
$home,'noredirect'); |
$next_url,$extra_env); |
$r->header_out('Set-cookie',"lonID=$cookie; path=/"); |
return OK; |
&Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'), |
|
$cookie); |
|
$env{'form.selectrole'}='1'; |
|
$env{'form.'.$data{'role'}}='1'; |
|
return &Apache::lonroles::handler($r); |
|
} |
} |
|
|
1; |
1; |