--- loncom/auth/migrateuser.pm 2022/06/30 21:04:13 1.63 +++ loncom/auth/migrateuser.pm 2024/02/09 20:08:17 1.68 @@ -1,7 +1,7 @@ # The LearningOnline Network # Starts a user off based of an existing token. # -# $Id: migrateuser.pm,v 1.63 2022/06/30 21:04:13 raeburn Exp $ +# $Id: migrateuser.pm,v 1.68 2024/02/09 20:08:17 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,6 +42,10 @@ use CGI::Cookie; sub goto_login { my ($r,$domain,$data) = @_; + my $write_to_opener; + if (ref($data) eq 'HASH') { + $write_to_opener = $data->{'lcssowin'}; + } if ((ref($data) eq 'HASH') && ($data->{'lti.login'})) { &Apache::ltiauth::invalid_request($r,'22'); } else { @@ -52,7 +56,7 @@ sub goto_login { $url .= '?domain='.$domain; } $r->print(&Apache::loncommon::start_page('Going to login',undef, - {'redirect' => [0,$url],}). + {'redirect' => [0,$url,'',$write_to_opener],}). '
'.&mt('Transferring to login page.').'
'. &Apache::loncommon::end_page()); @@ -285,19 +289,27 @@ sub ip_changed { 'username' => $dataref->{'username'}, 'sessionserver' => $lonhost, ); - my @names = ('origurl','symb','role','linkprotuser','linkprotexit','linkprot','linkkey'); + my @names = ('origurl','symb','role','linkprotuser','linkprotexit','linkprot','linkkey','linkprotpbid','linkprotpburl'); foreach my $name (@names) { if ($dataref->{$name} ne '') { $info{$name} = $dataref->{$name}; } } + if ($info{'origurl'} eq '/adm/email') { + if (($dataref->{'display'}) && ($dataref->{'mailrecip'})) { + if (&unescape($dataref->{'mailrecip'}) eq $dataref->{'username'}.':'.$dataref->{'domain'}) { + $info{'display'} = $dataref->{'display'}; + $info{'mailrecip'} = $dataref->{'mailrecip'}; + } + } + } my $iptoken = &Apache::lonnet::tmpput(\%info,$switchto,'link'); unless ($iptoken eq 'conlost') { $url .= (($url =~ /\?/) ? '&' : '?') . 'iptoken='.$iptoken; } $r->print(&Apache::loncommon::start_page($title,undef, {'redirect' => - [2,$url],}). + [2,$url,'',$dataref->{'lcssowin'}],}). ''.$message.'
'. &Apache::loncommon::end_page()); @@ -336,7 +348,7 @@ sub logout { $r->headers_out->add('Set-cookie' => $c); } my $lonhost = $r->dir_config('lonHostID'); - my ($url,$token,$delay,%info,%user_info); + my ($url,$token,$delay,$write_to_opener,%info,%user_info); if (ref($data) eq 'HASH') { %user_info=('ip' => $ip, 'domain' => $data->{'domain'}, @@ -346,6 +358,7 @@ sub logout { 'origurl' => $data->{'origurl'}, 'symb' => $data->{'symb'}, 'server' => $lonhost); + $write_to_opener = $data->{'lcssowin'}; } $delay = 0.1; if (ref($linkprot_info) eq 'HASH') { @@ -379,7 +392,7 @@ sub logout { $r->send_http_header; $r->print( &Apache::loncommon::start_page('Updating Session ...',undef, - {'redirect' => [$delay,$url], + {'redirect' => [$delay,$url,'',$write_to_opener], 'only_body' => 1,}). &Apache::loncommon::end_page()); if ($env{'request.balancercookie'}) { @@ -739,11 +752,20 @@ sub handler { if ($handle) { &Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'), $handle); - my $checklaunch; + my ($checklaunch,$prevlaunch); if ($data{'origurl'} =~ m{^/tiny/$match_domain/\w+$}) { unless ($env{'request.linkprot'} eq $data{'linkprot'}) { $checklaunch = 1; } + unless ($env{'request.linkprotexit'} eq $data{'linkprotexit'}) { + $checklaunch = 1; + } + unless ($env{'request.linkprotpbid'} eq $data{'linkprotpbid'}) { + $checklaunch = 1; + } + unless ($env{'request.linkprotpburl'} eq $data{'linkprotpburl'}) { + $checklaunch = 1; + } unless ($env{'request.linkkey'} eq $data{'linkkey'}) { $checklaunch = 1; } @@ -755,7 +777,7 @@ sub handler { if (($env{'user.name'} ne $data{'username'}) || ($env{'user.domain'} ne $data{'domain'})) { my %linkprot_env; - foreach my $item ('linkprot','deeplink.login') { + foreach my $item ('linkprot','linkprotexit','linkprotpbid','linkprotpburl','deeplink.login') { if ($data{$item}) { $linkprot_env{$item} = $data{$item}; } @@ -764,6 +786,9 @@ sub handler { return OK; } &Apache::lonnet::appenv({'request.linkprot' => $data{'linkprot'}}); + if ($data{'linkprotexit'}) { + &Apache::lonnet::appenv({'request.linkprotexit' => $data{'linkprotexit'}}); + } if ($env{'request.linkkey'}) { &Apache::lonnet::delenv('request.linkkey'); } @@ -817,6 +842,9 @@ sub handler { } } if ($data{'deeplink.login'}) { + if (($env{'request.deeplink.login'}) && ($env{'request.deeplink.login'} ne $data{'deeplink.login'})) { + $prevlaunch = $env{'request.deeplink.login'}; + } &Apache::lonnet::appenv({'request.deeplink.login' => $data{'deeplink.login'}}); } if ($data{'lti.login'}) { @@ -902,7 +930,7 @@ sub handler { my %info; if ($env{'request.linkprot'}) { $info{'linkprot'} = $env{'request.linkprot'}; - foreach my $item ('linkprotuser','linkprotexit') { + foreach my $item ('linkprotuser','linkprotexit','linkprotpbid','linkprotpburl') { if ($data{$item}) { $info{$item} = $data{$item}; } @@ -913,6 +941,7 @@ sub handler { $info{'origurl'} = $data{'origurl'}; if ($checklaunch) { $info{'checklaunch'} = 1; + $info{'prevlaunch'} = $prevlaunch; } my $token = &Apache::lonnet::tmpput(\%info,$r->dir_config('lonHostID'),'link'); unless (($token eq 'con_lost') || ($token eq 'refused') || ($token =~ /^error:/) || @@ -958,8 +987,17 @@ sub handler { 'user.linkproturi' => $linkuri, 'request.linkprot' => $data{'linkprot'}}; } + if ($data{'linkprotexit'}) { + $extra_env->{'request.linkprotexit'} = $data{'linkprotexit'}; + } + if ($data{'linkprotpbid'}) { + $extra_env->{'request.linkprotpbid'} = $data{'linkprotpbid'}; + } + if ($data{'linkprotpburl'}) { + $extra_env->{'request.linkprotpburl'} = $data{'linkprotpburl'}; + } } - foreach my $item ('linkprotuser','linkprotexit') { + foreach my $item ('linkprotuser','linkprotexit','linkprotpbid','linkprotpburl') { if ($data{$item} ne '') { $form{$item} = $data{$item}; } @@ -982,6 +1020,13 @@ sub handler { $extra_env = {'request.deeplink.login' => $data{'deeplink.login'}}; } } + if ($desturl eq '/adm/email') { + if (($data{'display'}) && ($data{'mailrecip'})) { + if (&unescape($data{'mailrecip'}) eq "$data{'username'}:$data{'domain'}") { + $form{'display'} = &unescape($data{'display'}); + } + } + } } my $skipcritical; if ($data{'lti.login'}) { @@ -993,7 +1038,7 @@ sub handler { } &Apache::lonauth::success($r,$data{'username'},$data{'domain'}, $home,$desturl,$extra_env,\%form,$skipcritical,'', - $expirepub); + $expirepub,$data{'lcssowin'}); } return OK; } @@ -1061,7 +1106,16 @@ sub handler { } if ($data{'linkprot'}) { $extra_env->{'request.linkprot'} = $data{'linkprot'}; - foreach my $item ('linkprotuser','linkprotexit') { + if ($data{'linkprotexit'}) { + $extra_env->{'request.linkprotexit'} = $data{'linkprotexit'}; + } + if ($data{'linkprotpbid'}) { + $extra_env->{'request.linkprotpassbid'} = $data{'linkprotpbid'}; + } + if ($data{'linkprotpburl'}) { + $extra_env->{'request.linkprotpassburl'} = $data{'linkprotpburl'}; + } + foreach my $item ('linkprotuser','linkprotexit','linkprotpbid','linkprotpburl') { if ($data{$item}) { $form{'request.'.$item} = $data{$item}; } @@ -1071,7 +1125,7 @@ sub handler { } } &Apache::lonauth::success($r,$data{'username'},$data{'domain'},$home, - $next_url,$extra_env,\%form,'',$cid); + $next_url,$extra_env,\%form,'',$cid,'',$data{'lcssowin'}); } return OK; }