Annotation of loncom/auth/migrateuser.pm, revision 1.25.2.5.2.3
1.1 albertel 1: # The LearningOnline Network
2: # Starts a user off based of an existing token.
3: #
1.25.2.5.2.3! raeburn 4: # $Id: migrateuser.pm,v 1.25.2.5.2.2 2022/02/07 12:05:05 raeburn Exp $
1.1 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
1.2 albertel 29: package Apache::migrateuser;
1.1 albertel 30:
31: use strict;
1.19 raeburn 32: use LONCAPA qw(:DEFAULT :match);
1.25.2.5 raeburn 33: use Apache::Constants qw(:common :http :methods :remotehost);
1.1 albertel 34: use Apache::lonauth;
35: use Apache::lonnet;
1.6 albertel 36: use Apache::lonlocal;
1.18 raeburn 37: use Apache::lonlogin();
1.25.2.5.2.2 raeburn 38: use CGI::Cookie;
1.1 albertel 39:
40: sub goto_login {
1.24 raeburn 41: my ($r,$domain) = @_;
1.2 albertel 42: &Apache::loncommon::content_type($r,'text/html');
43: $r->send_http_header;
1.24 raeburn 44: my $url = '/adm/login';
45: if ($domain) {
46: $url .= '?domain='.$domain;
47: }
1.5 albertel 48: $r->print(&Apache::loncommon::start_page('Going to login',undef,
1.24 raeburn 49: {'redirect' => [0,$url],}).
1.5 albertel 50: '<h1>'.&mt('One moment please...').'</h1>'.
51: '<p>'.&mt('Transferring to login page.').'</p>'.
52: &Apache::loncommon::end_page());
1.2 albertel 53: return OK;
1.1 albertel 54: }
55:
1.7 albertel 56: sub sso_check {
57: my ($data) = @_;
1.8 albertel 58: my %extra_env;
1.18 raeburn 59: if (ref($data) eq 'HASH') {
60: if ($data->{'sso.login'}) {
61: $extra_env{'request.sso.login'} = $data->{'sso.login'};
62: }
63: if ($data->{'sso.reloginserver'}) {
64: $extra_env{'request.sso.reloginserver'} =
65: $data->{'sso.reloginserver'};
66: }
1.7 albertel 67: }
1.18 raeburn 68: return \%extra_env;
69: }
70:
71: sub ip_changed {
72: my ($r,$udom,$camefrom,$dataref) = @_;
73: &Apache::loncommon::content_type($r,'text/html');
74: $r->send_http_header;
75: if (ref($dataref) eq 'HASH') {
76: my $title = 'LON-CAPA Session redirected';
77: my $message = &mt('Your internet address has changed since you logged in.');
78: my $rule_in_effect;
1.22 raeburn 79: if ($dataref->{'balancer'}) {
80: my $baldom = &Apache::lonnet::host_domain($camefrom);
81: my $balprimaryid = &Apache::lonnet::domain($baldom,'primary');
82: my $balintdom = &Apache::lonnet::internet_dom($balprimaryid);
83: my $uprimaryid = &Apache::lonnet::domain($udom,'primary');
84: my $uintdom = &Apache::lonnet::internet_dom($uprimaryid);
85: my $dom_in_use;
86: if (($uintdom ne '') && ($uintdom eq $balintdom)) {
87: $dom_in_use = $udom;
88: } else {
89: $dom_in_use = $baldom;
1.21 raeburn 90: }
1.22 raeburn 91: my ($result,$cached)=&Apache::lonnet::is_cached_new('loadbalancing',$dom_in_use);
1.18 raeburn 92: unless (defined($cached)) {
93: my $cachetime = 60*60*24;
94: my %domconfig =
1.22 raeburn 95: &Apache::lonnet::get_dom('configuration',['loadbalancing'],$dom_in_use);
1.18 raeburn 96: if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
1.22 raeburn 97: $result = &Apache::lonnet::do_cache_new('loadbalancing',$dom_in_use,
1.18 raeburn 98: $domconfig{'loadbalancing'},$cachetime);
99: }
100: }
101: if (ref($result) eq 'HASH') {
102: (undef,my $currtargets,my $currrules) =
103: &Apache::lonnet::check_balancer_result($result,$dataref->{'server'});
104: if (ref($currrules) eq 'HASH') {
105: if ($dataref->{'sso.login'}) {
106: if ($currrules->{'_LC_ipchangesso'} ne '') {
107: $rule_in_effect = $currrules->{'_LC_ipchangesso'};
108: }
109: } else {
110: if ($currrules->{'_LC_ipchange'} ne '') {
111: $rule_in_effect = $currrules->{'_LC_ipchange'};
112: }
113: }
114: }
115: }
116: }
117: my $url;
118: my $lonhost= $r->dir_config('lonHostID');
119: my $switchto = $lonhost;
1.23 raeburn 120: if ($rule_in_effect ne 'offloadedto') {
1.18 raeburn 121: my $hosthere;
1.23 raeburn 122: my @ids=&Apache::lonnet::current_machine_ids();
123: unless ($rule_in_effect eq 'balancer') {
124: if (grep(/^\Q$rule_in_effect\E$/,@ids)) {
125: $hosthere = 1;
126: }
127: }
128: unless ($hosthere) {
129: if ($dataref->{'role'}) {
130: my ($adom,$aname);
131: if ($dataref->{'role'} =~ m{^au\./($match_domain)/$}) {
132: $adom = $1;
133: $aname = $dataref->{'username'};
134: } elsif ($dataref->{'role'} =~ m{^(?:ca|aa)\./($match_domain)/($match_username)$}) {
135: $adom = $1;
136: $aname = $2;
137: }
138: if ($adom ne '' && $aname ne '') {
139: my $ahome = &Apache::lonnet::homeserver($aname,$adom);
140: unless ($ahome eq 'no_host') {
141: if ($ahome && grep(/^\Q$ahome\E$/,@ids)) {
142: $hosthere = 1;
143: }
1.18 raeburn 144: }
145: }
146: }
147: }
1.23 raeburn 148: unless ($hosthere) {
149: my $hostname;
150: if ($rule_in_effect eq 'balancer') {
151: $hostname = &Apache::lonnet::hostname($dataref->{'server'});
152: if ($hostname) {
153: $switchto = $dataref->{'server'};
154: }
155: } else {
156: $hostname = &Apache::lonnet::hostname($rule_in_effect);
157: if ($hostname) {
158: $switchto = $rule_in_effect;
159: }
160: }
1.18 raeburn 161: if ($hostname) {
162: my $protocol = $Apache::lonnet::protocol{$switchto};
163: $protocol = 'http' if ($protocol ne 'https');
1.25.2.5 raeburn 164: my $alias = &Apache::lonnet::use_proxy_alias($r,$switchto);
165: $hostname = $alias if ($alias ne '');
1.18 raeburn 166: $url = $protocol.'://'.$hostname;
1.23 raeburn 167: if ($rule_in_effect eq 'balancer') {
168: $message .= '<br />'.
169: &mt('As a result, your LON-CAPA session is being redirected to the server where you originally logged in.');
170: } else {
171: $message .= '<br />'.
172: &mt('As a result, your LON-CAPA session is being redirected.');
173: }
1.18 raeburn 174: }
175: }
1.25.2.1 raeburn 176: unless ($hosthere) {
177: if (($dataref->{'balancer'}) && ($dataref->{'balcookie'})) {
178: &Apache::lonnet::delbalcookie($dataref->{'balcookie'},$dataref->{'balancer'});
179: }
180: }
1.18 raeburn 181: }
182: if ($dataref->{'sso.login'}) {
1.21 raeburn 183: $url .= '/adm/roles';
1.18 raeburn 184: } else {
1.21 raeburn 185: $url .= '/adm/login';
1.24 raeburn 186: if ($udom) {
187: $url .= '?domain='.$udom;
188: }
1.20 raeburn 189: $message .= '<br />'.&mt('You will need to provide your password one more time.');
1.18 raeburn 190: }
191: my %info= (
1.24 raeburn 192: 'domain' => $udom,
1.18 raeburn 193: 'username' => $dataref->{'username'},
194: 'sessionserver' => $lonhost,
195: );
1.25.2.5.2.1 raeburn 196: my @names = ('origurl','symb','role','linkprot','linkkey');
1.25.2.5 raeburn 197: foreach my $name (@names) {
198: if ($dataref->{$name} ne '') {
199: $info{$name} = $dataref->{$name};
200: }
1.18 raeburn 201: }
1.25.2.5 raeburn 202: my $iptoken = &Apache::lonnet::tmpput(\%info,$switchto,'link');
1.18 raeburn 203: unless ($iptoken eq 'conlost') {
1.25.2.5 raeburn 204: $url .= (($url =~ /\?/) ? '&' : '?') . 'iptoken='.$iptoken;
1.18 raeburn 205: }
206: $r->print(&Apache::loncommon::start_page($title,undef,
207: {'redirect' =>
208: [2,$url],}).
209: '<h1>'.&mt('One moment please...').'</h1>'.
210: '<p class="LC_warning">'.$message.'</p>'.
211: &Apache::loncommon::end_page());
212: } else {
213: return &goto_login($r);
1.10 raeburn 214: }
1.18 raeburn 215: return OK;
1.7 albertel 216: }
217:
1.25.2.5.2.2 raeburn 218: sub logout {
219: my ($r,$ip,$handle,$data,$lti_env) = @_;
220: my $lonidsdir=$r->dir_config('lonIDsDir');
221: if (unlink("$lonidsdir/$handle.id")) {
222: if (($env{'user.linkedenv'} =~ /^[a-f0-9]+_linked$/) &&
223: (-l "$lonidsdir/$env{'user.linkedenv'}.id") &&
224: (readlink("$lonidsdir/$env{'user.linkedenv'}.id") eq "$lonidsdir/$handle.id")) {
225: unlink("$lonidsdir/$env{'user.linkedenv'}.id");
226: }
227: }
228: my %temp=('logout' => time);
229: &Apache::lonnet::put('email_status',\%temp);
230: &Apache::lonnet::log($env{'user.domain'},
231: $env{'user.name'},
232: $env{'user.home'},
233: "Logout $ip");
234:
235: &Apache::loncommon::content_type($r,'text/html');
236:
237: #expire the cookies
238: my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
239: foreach my $name (keys(%cookies)) {
240: next unless ($name =~ /^lon(|S|Link|Pub)ID$/);
241: my $c = new CGI::Cookie(-name => $name,
242: -value => '',
243: -expires => '-10y',);
244: $r->headers_out->add('Set-cookie' => $c);
245: }
246: my (%info,%user_info,%lti_info);
247: if (ref($lti_env) eq 'HASH') {
248: foreach my $key (sort(keys(%{$lti_env}))) {
249: if ($key =~ /^request\.(.+)$/) {
250: $lti_info{$1} = $lti_env->{$key};
251: }
252: }
253: }
254: my $lonhost = $r->dir_config('lonHostID');
255: if (ref($data) eq 'HASH') {
256: %user_info=('ip' => $ip,
257: 'domain' => $data->{'domain'},
258: 'username' => $data->{'username'},
259: 'home' => $data->{'home'},
260: 'role' => $data->{'role'},
261: 'origurl' => $data->{'origurl'},
262: 'symb' => $data->{'symb'},
263: 'server' => $lonhost);
264: }
265: %info = (%user_info,%lti_info);
266: my $token = &Apache::lonnet::tmpput(\%info,$lonhost);
267: my $url = '/adm/migrateuser?token='.$token;
268: $r->send_http_header;
269: $r->print(
270: &Apache::loncommon::start_page('Updating Session ...',undef,
271: {'redirect' => [0.1,$url],
272: 'only_body' => 1,}).
273: &Apache::loncommon::end_page());
274: if ($env{'request.balancercookie'}) {
275: my ($balancer,$cookie) = split(/:/,$env{'request.balancercookie'});
276: if ((&Apache::lonnet::hostname($balancer)) && ($cookie =~ /^[a-f0-9]{32}$/)) {
277: $cookie = $env{'user.domain'}.'_'.$env{'user.name'}.'_'.$cookie;
278: &Apache::lonnet::delbalcookie($cookie,$balancer);
279: }
280: }
281: $r->register_cleanup(\&flush_course_logs);
282: return;
283: }
284:
1.1 albertel 285: sub handler {
286: my ($r) = @_;
1.25.2.5.2.1 raeburn 287:
1.1 albertel 288: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['token']);
1.4 albertel 289: my %data = &Apache::lonnet::tmpget($env{'form.token'});
1.13 raeburn 290: if (keys(%data) == 0) {
291: return &goto_login($r);
292: }
1.4 albertel 293: my $delete = &Apache::lonnet::tmpdel($env{'form.token'});
294:
1.6 albertel 295: &Apache::lonlocal::get_language_handle($r);
296:
1.4 albertel 297: if ($delete ne 'ok') {
298: return &goto_login($r);
299: }
1.2 albertel 300:
1.18 raeburn 301: if (!defined($data{'username'}) || !defined($data{'domain'})) {
302: return &goto_login($r);
303: }
1.25.2.5 raeburn 304: my $ip = &Apache::lonnet::get_requestor_ip($r,REMOTE_NOLOOKUP);
1.25.2.4 raeburn 305: if ($data{'ip'} ne $ip) {
1.24 raeburn 306: &Apache::lonnet::logthis('IP change when session migration requested -- was: '.
1.25.2.4 raeburn 307: $data{'ip'}.'; now: '.$ip.' for '.$data{'username'}.':'.$data{'domain'});
1.18 raeburn 308: return &ip_changed($r,$data{'domain'},$data{'server'},\%data);
1.2 albertel 309: }
310:
1.17 raeburn 311: &Apache::lonnet::logthis("Allowing access for $data{'username'}:$data{'domain'} to $data{'role'}");
1.2 albertel 312: my $home=&Apache::lonnet::homeserver($data{'username'},$data{'domain'});
1.24 raeburn 313: my $udom;
314: if (&Apache::lonnet::domain($data{'domain'})) {
315: $udom=$data{'domain'};
316: }
317: if ($home =~ /(con_lost|no_such_host)/) { return &goto_login($r,$udom); }
1.2 albertel 318:
1.8 albertel 319: my $extra_env = &sso_check(\%data);
1.25.2.1 raeburn 320: if (($data{'balancer'}) && ($data{'server'}) && ($data{'balcookie'})) {
321: if (ref($extra_env) eq 'HASH') {
322: $extra_env->{'request.balancercookie'} = $data{'server'}.':'.$data{'balcookie'};
323: } else {
324: $extra_env = { 'request.balancercookie' => $data{'server'}.':'.$data{'balcookie'} };
325: }
1.25.2.3 raeburn 326: } elsif (($data{'server'}) && ($data{'otherbalcookie'})) {
327: my ($balancer,$balcookie) = split(/:/,$data{'otherbalcookie'});
328: if (defined(&Apache::lonnet::hostname($balancer)) && $balcookie =~ /^[a-f0-9]{32}$/) {
329: my $baldom = &Apache::lonnet::host_domain($balancer);
330: if (&Apache::lonnet::shared_institution($baldom)) {
331: my $cookieid = join('_',$udom,$data{'username'},$balcookie);
332: &Apache::lonnet::updatebalcookie($cookieid,$balancer,$data{'server'});
333: if (ref($extra_env) eq 'HASH') {
334: $extra_env->{'request.balancercookie'} = $data{'otherbalcookie'};
335: } else {
336: $extra_env = { 'request.balancercookie' => $data{'otherbalcookie'} };
337: }
338: }
339: }
1.25.2.1 raeburn 340: }
1.8 albertel 341:
1.25.2.2 raeburn 342: my (%form,$cid);
1.16 raeburn 343: if ($data{'symb'} ne '') {
344: $form{'symb'} = $data{'symb'};
345: }
1.21 raeburn 346: if ($data{'iptoken'} ne '') {
347: $form{'iptoken'} = $data{'iptoken'};
348: }
1.25 raeburn 349: if ($data{'noloadbalance'} ne '') {
350: $form{'noloadbalance'} = $data{'noloadbalance'};
351: }
1.25.2.2 raeburn 352: if ($data{'role'}) {
353: if ($data{'role'} =~ m{\./($match_domain)/($match_courseid)(?:/\w+|$)}) {
354: unless (&Apache::lonnet::homeserver($2,$1) eq 'no_host') {
355: $cid = $1.'_'.$2;
356: }
357: }
358: } else {
1.25.2.5 raeburn 359: my ($handle,$expirepub);
1.25.2.5.2.1 raeburn 360: $handle = &Apache::lonnet::check_for_valid_session($r);
1.25.2.5 raeburn 361:
362: # For "public user" - remove any existing "public" cookie so actual user is logged in.
363: if ($handle) {
364: if ($handle=~/^publicuser\_/) {
365: my $lonidsdir=$r->dir_config('lonIDsDir');
366: if ($lonidsdir ne '') {
367: unlink("$lonidsdir/$handle.id");
368: }
369: undef($handle);
370: $expirepub = 1;
371: }
372: }
1.12 albertel 373: if ($handle) {
1.11 albertel 374: &Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'),
375: $handle);
1.25.2.5.2.1 raeburn 376: my $checklaunch;
377: if ($data{'origurl'} =~ m{^/tiny/$match_domain/\w+$}) {
1.25.2.5.2.3! raeburn 378: unless ($env{'request.linkprot'} eq $data{'linkprot'}) {
! 379: $checklaunch = 1;
1.25.2.5.2.1 raeburn 380: }
1.25.2.5.2.3! raeburn 381: unless ($env{'request.linkkey'} eq $data{'linkkey'}) {
! 382: $checklaunch = 1;
! 383: }
! 384: unless ($env{'request.deeplink.login'} eq $data{'deeplink.login'}) {
! 385: $checklaunch = 1;
1.25.2.5.2.1 raeburn 386: }
387: }
388: if ($data{'linkprot'} ne '') {
1.25.2.5.2.2 raeburn 389: if (($env{'user.name'} ne $data{'username'}) ||
390: ($env{'user.domain'} ne $data{'domain'})) {
391: my %linkprot_env;
392: foreach my $item ('linkprot','deeplink.login') {
393: if ($data{$item}) {
394: $linkprot_env{'request.'.$item} = $data{$item};
395: }
396: }
397: &logout($r,$ip,$handle,\%data,\%linkprot_env);
398: return OK;
399: }
1.25.2.5.2.1 raeburn 400: &Apache::lonnet::appenv({'request.linkprot' => $data{'linkprot'}});
401: if ($env{'request.linkkey'}) {
402: &Apache::lonnet::delenv('request.linkkey');
403: }
404: my ($linkprotector,$deeplink) = split(/:/,$data{'linkprot'},2);
405: if ($env{'user.linkprotector'}) {
406: my @protectors = split(/,/,$env{'user.linkprotector'});
407: unless (grep(/^\Q$linkprotector\E$/,@protectors)) {
408: push(@protectors,$linkprotector);
409: @protectors = sort { $a <=> $b } @protectors;
410: &Apache::lonnet::appenv({'user.linkprotector' => join(',',@protectors)});
411: }
412: } else {
413: &Apache::lonnet::appenv({'user.linkprotector' => $linkprotector });
414: }
415: if ($env{'user.linkproturi'}) {
416: my @proturis = split(/,/,$env{'user.linkproturi'});
417: unless(grep(/^\Q$deeplink\E$/,@proturis)) {
418: push(@proturis,$deeplink);
419: @proturis = sort @proturis;
420: &Apache::lonnet::appenv({'user.linkproturi' => join(',',@proturis)});
421: }
422: } else {
423: &Apache::lonnet::appenv({'user.linkproturi' => $deeplink});
424: }
425: } elsif ($data{'linkkey'} ne '') {
426: &Apache::lonnet::appenv({'request.linkkey' => $data{'linkkey'}});
427: if ($env{'request.linkprot'}) {
428: &Apache::lonnet::delenv('request.linkprot');
429: }
430: my $deeplink = $data{'deeplink.login'};
431: my $linkkey = $data{'linkkey'};
432: if ($env{'user.deeplinkkey'} ne '') {
433: my @linkkeys = split(/,/,$env{'user.deeplinkkey'});
434: unless (grep(/^\Q$linkkey\E$/,@linkkeys)) {
435: push(@linkkeys,$linkkey);
436: &Apache::lonnet::appenv({'user.deeplinkkey' => join(',',sort(@linkkeys))});
437: }
438: } else {
439: &Apache::lonnet::appenv({'user.deeplinkkey' => $linkkey});
440: }
441: if ($deeplink) {
442: if ($env{'user.keyedlinkuri'}) {
443: my @keyeduris = split(/,/,$env{'user.keyedlinkuri'});
444: unless (grep(/^\Q$deeplink\E$/,@keyeduris)) {
445: push(@keyeduris,$deeplink);
446: &Apache::lonnet::appenv({'user.keyedlinkuri' => join(',',sort(@keyeduris))});
447: }
448: } else {
449: &Apache::lonnet::appenv({'user.keyedlinkuri' => $deeplink});
450: }
451: }
452: }
453: if ($data{'deeplink.login'}) {
454: &Apache::lonnet::appenv({'request.deeplink.login' => $data{'deeplink.login'}});
455: }
1.14 raeburn 456: if ($data{'origurl'} ne '') {
1.25.2.5.2.1 raeburn 457: my $dest = $data{'origurl'};
458: if (($env{'request.deeplink.login'} eq $data{'origurl'}) &&
459: (($env{'request.linkprot'}) || ($env{'request.linkkey'} ne ''))) {
460: my %info;
461: if ($env{'request.linkprot'}) {
462: $info{'linkprot'} = $env{'request.linkprot'};
463: } elsif ($env{'request.linkkey'} ne '') {
464: $info{'linkkey'} = $env{'request.linkkey'};
465: }
466: $info{'origurl'} = $data{'origurl'};
467: if ($checklaunch) {
468: $info{'checklaunch'} = 1;
469: }
470: my $token = &Apache::lonnet::tmpput(\%info,$r->dir_config('lonHostID'),'link');
471: unless (($token eq 'con_lost') || ($token eq 'refused') ||
472: ($token eq 'unknown_cmd') || ($token eq 'no_such_host')) {
473: $dest .= (($dest =~ /\?/) ? '&' : '?') . 'ttoken='.$token;
474: }
475: }
476: $r->internal_redirect($dest);
1.14 raeburn 477: } elsif ($env{'request.course.id'}) {
478: $r->internal_redirect('/adm/navmaps');
1.11 albertel 479: } else {
480: $r->internal_redirect('/adm/roles');
481: }
482: } else {
1.14 raeburn 483: my $desturl = '/adm/roles';
484: if ($data{'origurl'} ne '') {
485: $desturl = $data{'origurl'};
1.25.2.5.2.1 raeburn 486: if ($data{'linkprot'}) {
487: my ($linkprotector,$linkuri) = split(/:/,$data{'linkprot'},2);
488: if ($linkprotector) {
489: if (ref($extra_env) eq 'HASH') {
490: $extra_env->{'user.linkprotector'} = $linkprotector;
491: $extra_env->{'user.linkproturi'} = $linkuri;
492: $extra_env->{'request.linkprot'} = $data{'linkprot'};
493: } else {
494: $extra_env = {'user.linkprotector' => $linkprotector,
495: 'user.linkproturi' => $linkuri,
496: 'request.linkprot' => $data{'linkprot'}};
497: }
498: }
499: } elsif ($data{'linkkey'}) {
500: if (ref($extra_env) eq 'HASH') {
501: $extra_env->{'user.deeplinkkey'} = $data{'linkkey'};
502: $extra_env->{'user.keyedlinkuri'} = $data{'deeplink.login'};
503: $extra_env->{'request.linkkey'} = $data{'linkkey'};
504: } else {
505: $extra_env = {'user.deeplinkkey' => $data{'linkkey'},
506: 'user.keyedlinkuri' => $data{'deeplink.login'},
507: 'request.linkkey' => $data{'linkkey'}};
508: }
509: }
510: if ($data{'deeplink.login'}) {
511: if (ref($extra_env) eq 'HASH') {
512: $extra_env->{'request.deeplink.login'} = $data{'deeplink.login'};
513: } else {
514: $extra_env = {'request.deeplink.login' => $data{'deeplink.login'}};
515: }
516: }
1.14 raeburn 517: }
1.11 albertel 518: &Apache::lonauth::success($r,$data{'username'},$data{'domain'},
1.25.2.5 raeburn 519: $home,$desturl,$extra_env,\%form,'',
520: $expirepub);
1.11 albertel 521: }
1.1 albertel 522: return OK;
523: }
1.6 albertel 524:
525: my $next_url='/adm/roles?selectrole=1&'.&escape($data{'role'}).'=1';
1.15 raeburn 526: if ($data{'origurl'} ne '') {
527: $next_url .= '&orgurl='.&escape($data{'origurl'});
528: }
1.25.2.5.2.1 raeburn 529: if ($data{'deeplink.login'}) {
530: if (ref($extra_env) eq 'HASH') {
531: $extra_env->{'request.deeplink.login'} = $data{'deeplink.login'};
532: } else {
533: $extra_env = {'request.deeplink.login' => $data{'deeplink.login'}};
534: }
535: if ($data{'linkprot'}) {
536: $extra_env->{'request.linkprot'} = $data{'linkprot'};
537: } elsif ($data{'linkkey'} ne '') {
538: $extra_env->{'request.linkkey'} = $data{'linkkey'};
539: }
540: }
1.6 albertel 541: &Apache::lonauth::success($r,$data{'username'},$data{'domain'},$home,
1.25.2.2 raeburn 542: $next_url,$extra_env,\%form,$cid);
1.6 albertel 543: return OK;
1.1 albertel 544: }
545:
546: 1;
547: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>