--- loncom/auth/migrateuser.pm 2005/10/28 21:51:43 1.3 +++ loncom/auth/migrateuser.pm 2018/04/14 01:50:43 1.28 @@ -1,7 +1,7 @@ # The LearningOnline Network # Starts a user off based of an existing token. # -# $Id: migrateuser.pm,v 1.3 2005/10/28 21:51:43 albertel Exp $ +# $Id: migrateuser.pm,v 1.28 2018/04/14 01:50:43 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -29,62 +29,454 @@ package Apache::migrateuser; use strict; +use LONCAPA qw(:DEFAULT :match); use Apache::Constants qw(:common :http :methods); use Apache::lonauth; use Apache::lonnet; +use Apache::lonlocal; +use Apache::lonlogin(); +use Apache::ltiauth; +use CGI::Cookie; sub goto_login { - my ($r) = @_; + my ($r,$domain,$data) = @_; + if ((ref($data) eq 'HASH') && ($data->{'lti.login'})) { + &Apache::ltiauth::invalid_request($r,'22'); + } else { + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + my $url = '/adm/login'; + if ($domain) { + $url .= '?domain='.$domain; + } + $r->print(&Apache::loncommon::start_page('Going to login',undef, + {'redirect' => [0,$url],}). + '
'.&mt('Transferring to login page.').'
'. + &Apache::loncommon::end_page()); + } + return OK; +} + +sub sso_check { + my ($data) = @_; + my %extra_env; + if (ref($data) eq 'HASH') { + 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 lti_check { + my ($data) = @_; + my %lti_env; + if (ref($data) eq 'HASH') { + if ($data->{'lti.login'}) { + $lti_env{'request.lti.login'} = $data->{'lti.login'}; + if ($data->{'lti.reqcrs'}) { + $lti_env{'request.lti.reqcrs'} = $data->{'lti.reqcrs'}; + } + if ($data->{'lti.reqrole'}) { + $lti_env{'request.lti.reqrole'} = $data->{'lti.reqrole'}; + } + if ($data->{'lti.selfenrollrole'}) { + $lti_env{'request.lti.selfenrollrole'} = $data->{'lti.selfenrollrole'}; + } + } + if ($data->{'lti.passbackid'}) { + $lti_env{'request.lti.passbackid'} = $data->{'lti.passbackid'}; + } + if ($data->{'lti.passbackurl'}) { + $lti_env{'request.lti.passbackurl'} = $data->{'lti.passbackurl'}; + } + if ($data->{'lti.rosterid'}) { + $lti_env{'request.lti.rosterid'} = $data->{'lti.rosterid'}; + } + if ($data->{'lti.rosterurl'}) { + $lti_env{'request.lti.rosterurl'} = $data->{'lti.rosterurl'}; + } + } + return \%lti_env; +} + +sub ip_changed { + my ($r,$udom,$camefrom,$dataref) = @_; &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - $r->print(<- Transferring to login page. - Continue -
- -