Annotation of loncom/auth/lonauth.pm, revision 1.169
1.136 kruse 1: # The LearningOnline Network
2: # User Authentication Module
3: #
1.169 ! raeburn 4: # $Id: lonauth.pm,v 1.168 2021/10/26 15:52:54 raeburn Exp $
1.136 kruse 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:
29: package Apache::lonauth;
30:
31: use strict;
1.140 raeburn 32: use LONCAPA qw(:DEFAULT :match);
1.136 kruse 33: use Apache::Constants qw(:common);
34: use CGI qw(:standard);
35: use Apache::loncommon();
36: use Apache::lonnet;
37: use Apache::lonmenu();
38: use Apache::createaccount;
1.149 raeburn 39: use Apache::ltiauth;
1.136 kruse 40: use Fcntl qw(:flock);
41: use Apache::lonlocal;
42: use Apache::File();
43: use HTML::Entities;
1.143 raeburn 44: use Digest::MD5;
1.136 kruse 45:
46: # ------------------------------------------------------------ Successful login
47: sub success {
48: my ($r, $username, $domain, $authhost, $lowerurl, $extra_env,
1.159 raeburn 49: $form,$skipcritical,$cid) = @_;
1.136 kruse 50:
51: # ------------------------------------------------------------ Get cookie ready
52: my $cookie =
53: &Apache::loncommon::init_user_environment($r, $username, $domain,
54: $authhost, $form,
55: {'extra_env' => $extra_env,});
56:
57: my $public=($username eq 'public' && $domain eq 'public');
58:
59: if ($public or $lowerurl eq 'noredirect') { return $cookie; }
60:
61: # -------------------------------------------------------------------- Log this
62:
1.162 raeburn 63: my $ip = &Apache::lonnet::get_requestor_ip();
1.136 kruse 64: &Apache::lonnet::log($domain,$username,$authhost,
1.162 raeburn 65: "Login $ip");
1.136 kruse 66:
67: # ------------------------------------------------- Check for critical messages
68:
1.149 raeburn 69: unless ($skipcritical) {
70: my @what=&Apache::lonnet::dump('critical',$domain,$username);
71: if ($what[0]) {
72: if (($what[0] ne 'con_lost') && ($what[0]!~/^error\:/)) {
73: $lowerurl='/adm/email?critical=display';
74: }
1.136 kruse 75: }
76: }
77:
1.143 raeburn 78: # ----------------------------------------------------------- Get cookies ready
79: my ($securecookie,$defaultcookie);
1.154 raeburn 80: my $ssl = $r->subprocess_env('https');
81: if ($ssl) {
82: $securecookie="lonSID=$cookie; path=/; HttpOnly; secure";
1.143 raeburn 83: my $lonidsdir=$r->dir_config('lonIDsDir');
84: if (($lonidsdir) && (-e "$lonidsdir/$cookie.id")) {
85: my $linkname=substr(Digest::MD5::md5_hex(Digest::MD5::md5_hex(time(). {}. rand(). $$)), 0, 32).'_linked';
86: if (-e "$lonidsdir/$linkname.id") {
87: unlink("$lonidsdir/$linkname.id");
88: }
89: my $made_symlink = eval { symlink("$lonidsdir/$cookie.id",
90: "$lonidsdir/$linkname.id"); 1 };
91: if ($made_symlink) {
92: $defaultcookie = "lonLinkID=$linkname; path=/; HttpOnly;";
1.154 raeburn 93: &Apache::lonnet::appenv({'user.linkedenv' => $linkname});
1.143 raeburn 94: }
95: }
96: } else {
97: $defaultcookie = "lonID=$cookie; path=/; HttpOnly;";
98: }
1.136 kruse 99: # -------------------------------------------------------- Menu script and info
100: my $destination = $lowerurl;
1.149 raeburn 101: if ($env{'request.lti.login'}) {
102: if (($env{'request.lti.reqcrs'}) && ($env{'request.lti.reqrole'} eq 'cc')) {
103: &Apache::loncommon::content_type($r,'text/html');
104: if ($securecookie) {
105: $r->headers_out->add('Set-cookie' => $securecookie);
106: }
107: if ($defaultcookie) {
108: $r->headers_out->add('Set-cookie' => $defaultcookie);
109: }
110: $r->send_http_header;
1.152 raeburn 111: if (ref($form) eq 'HASH') {
1.158 raeburn 112: $form->{'lti.login'} = $env{'request.lti.login'};
1.152 raeburn 113: $form->{'lti.reqcrs'} = $env{'request.lti.reqcrs'};
114: $form->{'lti.reqrole'} = $env{'request.lti.reqrole'};
115: $form->{'lti.sourcecrs'} = $env{'request.lti.sourcecrs'};
116: }
1.149 raeburn 117: &Apache::ltiauth::lti_reqcrs($r,$domain,$form,$username,$domain);
118: return;
119: }
120: if ($env{'request.lti.selfenrollrole'}) {
121: if (&Apache::ltiauth::lti_enroll($username,$domain,
122: $env{'request.lti.selfenrollrole'}) eq 'ok') {
123: $form->{'role'} = $env{'request.lti.selfenrollrole'};
124: &Apache::lonnet::delenv('request.lti.selfenrollrole');
125: } else {
126: &Apache::ltiauth::invalid_request($r,24);
127: }
128: }
129: }
1.136 kruse 130: if (defined($form->{role})) {
131: my $envkey = 'user.role.'.$form->{role};
132: my $now=time;
133: my $then=$env{'user.login.time'};
134: my $refresh=$env{'user.refresh.time'};
135: my $update=$env{'user.update.time'};
136: if (!$update) {
137: $update = $then;
138: }
139: if (exists($env{$envkey})) {
140: my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus);
141: &Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where,
142: \$trolecode,\$tstatus,\$tstart,\$tend);
143: if ($tstatus eq 'is') {
144: $destination .= ($destination =~ /\?/) ? '&' : '?';
145: my $newrole = &HTML::Entities::encode($form->{role},'"<>&');
146: $destination .= 'selectrole=1&'.$newrole.'=1';
147: }
148: }
149: }
150: if (defined($form->{symb})) {
151: my $destsymb = $form->{symb};
1.159 raeburn 152: my $encrypted;
153: if ($destsymb =~ m{^/enc/}) {
154: $encrypted = 1;
155: if ($cid) {
156: $destsymb = &Apache::lonenc::unencrypted($destsymb,$cid);
157: }
158: }
1.136 kruse 159: $destination .= ($destination =~ /\?/) ? '&' : '?';
160: if ($destsymb =~ /___/) {
161: my ($map,$resid,$desturl)=split(/___/,$destsymb);
1.137 raeburn 162: $desturl = &Apache::lonnet::clutter($desturl);
1.159 raeburn 163: if ($encrypted) {
164: $desturl = &Apache::lonenc::encrypted($desturl,1,$cid);
165: $destsymb = $form->{symb};
166: }
1.136 kruse 167: $desturl = &HTML::Entities::encode($desturl,'"<>&');
168: $destsymb = &HTML::Entities::encode($destsymb,'"<>&');
169: $destination .= 'destinationurl='.$desturl.
170: '&destsymb='.$destsymb;
1.159 raeburn 171: } elsif (!$encrypted) {
1.136 kruse 172: $destsymb = &HTML::Entities::encode($destsymb,'"<>&');
173: $destination .= 'destinationurl='.$destsymb;
174: }
175: }
176: if ($destination =~ m{^/adm/roles}) {
177: $destination .= ($destination =~ /\?/) ? '&' : '?';
178: $destination .= 'source=login';
179: }
180:
1.169 ! raeburn 181: if (($env{'request.deeplink.login'} eq $lowerurl) &&
! 182: (($env{'request.linkprot'}) || ($env{'request.linkkey'} ne ''))) {
! 183: my %info;
! 184: if ($env{'request.linkprot'}) {
! 185: $info{'linkprot'} = $env{'request.linkprot'};
! 186: } elsif ($env{'request.linkkey'} ne '') {
! 187: $info{'linkkey'} = $env{'request.linkkey'};
! 188: }
! 189: $info{'origurl'} = $lowerurl;
! 190: my $token = &Apache::lonnet::tmpput(\%info,$r->dir_config('lonHostID'),'link');
! 191: unless (($token eq 'con_lost') || ($token eq 'refused') ||
! 192: ($token eq 'unknown_cmd') || ($token eq 'no_such_host')) {
! 193: $destination .= (($destination =~ /\?/) ? '&' : '?') . 'ttoken='.$token;
! 194: }
! 195: }
! 196:
1.150 raeburn 197: my $windowname = 'loncapaclient';
198: if ($env{'request.lti.login'}) {
199: $windowname .= 'lti';
200: }
201: my $windowinfo = Apache::lonhtmlcommon::scripttag('self.name="'.$windowname.'";');
1.136 kruse 202: my $brcrum = [{'href' => '',
203: 'text' => 'Successful Login'},];
1.140 raeburn 204: my $args = {'bread_crumbs' => $brcrum,};
205: unless ((defined($form->{role})) || (defined($form->{symb}))) {
206: my $update=$env{'user.update.time'};
207: if (!$update) {
208: $update = $env{'user.login.time'};
209: }
210: my %roles_in_env;
211: my $showcount = &Apache::lonroles::roles_from_env(\%roles_in_env,$update);
212: if ($showcount == 1) {
213: foreach my $rolecode (keys(%roles_in_env)) {
214: my ($cid) = ($rolecode =~ m{^\Quser.role.st./\E($match_domain/$match_courseid)(?:/|$)});
215: if ($cid) {
216: my %coursedescription =
217: &Apache::lonnet::coursedescription($cid,{'one_time' => '1'});
218: if ($coursedescription{'type'} eq 'Placement') {
219: $args->{'crstype'} = 'Placement';
220: }
221: last;
222: }
223: }
224: }
225: }
1.136 kruse 226:
227: # ------------------------------------------------- Output for successful login
228:
229: &Apache::loncommon::content_type($r,'text/html');
1.143 raeburn 230: if ($securecookie) {
231: $r->headers_out->add('Set-cookie' => $securecookie);
232: }
233: if ($defaultcookie) {
234: $r->headers_out->add('Set-cookie' => $defaultcookie);
235: }
1.136 kruse 236: $r->send_http_header;
237:
1.153 raeburn 238: my ($start_page,$js,$pagebody,$end_page);
1.151 raeburn 239: if ($env{'request.lti.login'}) {
1.153 raeburn 240: $args = {'only_body' => 1};
241: if ($env{'request.lti.target'} eq '') {
242: my $ltitarget = (($destination =~ /\?/) ? '&' : '?').
243: 'ltitarget=iframe';
244: $js = <<"ENDJS";
245:
246: <script type="text/javascript">
247: // <![CDATA[
248: function setLTItarget() {
249: var newloc = '$destination';
250: if (parent !== window) {
251: newloc += '$ltitarget';
252: }
253: window.location.href=newloc;
254: }
255: // ]]>
256: </script>
257:
258: ENDJS
259: $args->{'add_entries'} = {'onload' => "javascript:setLTItarget();"};
260: $pagebody = '<noscript><span class="LC_warning">'
261: .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
262: .'</span></noscript>';
263: } else {
264: $args->{'redirect'} = [0,$destination,1];
265: }
266: $start_page=&Apache::loncommon::start_page('',$js,$args);
1.151 raeburn 267: } else {
1.153 raeburn 268: $args->{'redirect'} = [0,$destination];
1.151 raeburn 269: $start_page=&Apache::loncommon::start_page('Successful Login',
1.153 raeburn 270: $js,$args);
1.149 raeburn 271:
1.151 raeburn 272: my %lt=&Apache::lonlocal::texthash(
273: 'wel' => 'Welcome',
274: 'pro' => 'Login problems?',
275: );
276: $pagebody = "<h1>$lt{'wel'}</h1>\n".
277: &mt('Welcome to the Learning[_1]Online[_2] Network with CAPA. Please wait while your session is being set up.','<i>','</i>');
278: my $loginhelp = &loginhelpdisplay($domain);
279: if ($loginhelp) {
280: $pagebody .= '<p><a href="'.$loginhelp.'">'.$lt{'pro'}.'</a></p>';
281: }
1.136 kruse 282: }
1.153 raeburn 283: $end_page = &Apache::loncommon::end_page();
1.136 kruse 284: $r->print(<<ENDSUCCESS);
285: $start_page
286: $windowinfo
1.151 raeburn 287: $pagebody
1.136 kruse 288: $end_page
289: ENDSUCCESS
290: return;
291: }
292:
293: # --------------------------------------------------------------- Failed login!
294:
295: sub failed {
296: my ($r,$message,$form) = @_;
297: (undef,undef,undef,my $clientmathml,my $clientunicode) =
298: &Apache::loncommon::decode_user_agent();
299: my $args = {};
300: if ($clientunicode && !$clientmathml) {
301: $args = {'browser.unicode' => 1};
302: }
303:
304: my $start_page = &Apache::loncommon::start_page('Unsuccessful Login',undef,$args);
305: my $uname = &Apache::loncommon::cleanup_html($form->{'uname'});
306: my $udom = &Apache::loncommon::cleanup_html($form->{'udom'});
307: if (&Apache::lonnet::domain($udom,'description') eq '') {
308: undef($udom);
309: }
310: my $retry = '/adm/login';
311: if ($uname eq $form->{'uname'}) {
312: $retry .= '?username='.$uname;
313: }
314: if ($udom) {
315: $retry .= (($retry=~/\?/)?'&':'?').'domain='.$udom;
316: }
1.168 raeburn 317: my $lonhost = $r->dir_config('lonHostID');
318: my $querystr;
319: my $result = &set_retry_token($form,$lonhost,\$querystr);
320: if ($result eq 'fail') {
321: if (exists($form->{role})) {
322: my $role = &Apache::loncommon::cleanup_html($form->{role});
323: if ($role ne '') {
324: $retry .= (($retry=~/\?/)?'&':'?').'role='.$role;
325: }
326: }
327: if (exists($form->{symb})) {
328: my $symb = &Apache::loncommon::cleanup_html($form->{symb});
329: if ($symb ne '') {
330: $retry .= (($retry=~/\?/)?'&':'?').'symb='.$symb;
331: }
332: }
333: if (exists($form->{firsturl})) {
334: my $firsturl = &Apache::loncommon::cleanup_html($form->{firsturl});
335: if ($firsturl ne '') {
336: $retry .= (($retry=~/\?/)?'&':'?').'firsturl='.$firsturl;
337: if ($form->{firsturl} =~ m{^/tiny/$match_domain/\w+$}) {
338: unless (exists($form->{linkprot})) {
339: if (exists($form->{linkkey})) {
340: $retry .= 'linkkey='.$form->{linkkey};
341: }
1.157 raeburn 342: }
343: }
344: }
1.155 raeburn 345: }
1.168 raeburn 346: if (exists($form->{linkprot})) {
347: my $ltoken = &Apache::lonnet::tmpput({linkprot => $form->{'linkprot'}},
1.169 ! raeburn 348: $r->dir_config('lonHostID'),'retry');
1.168 raeburn 349: if ($ltoken) {
350: $retry .= (($retry =~ /\?/) ? '&' : '?').'ltoken='.$ltoken;
351: }
1.156 raeburn 352: }
1.168 raeburn 353: } elsif ($querystr ne '') {
354: $retry .= (($retry=~/\?/)?'&':'?').$querystr;
1.156 raeburn 355: }
1.136 kruse 356: my $end_page = &Apache::loncommon::end_page();
357: &Apache::loncommon::content_type($r,'text/html');
358: $r->send_http_header;
359: my @actions =
360: (&mt('Please [_1]log in again[_2].','<a href="'.$retry.'">','</a>'));
361: my $loginhelp = &loginhelpdisplay($udom);
362: if ($loginhelp) {
363: push(@actions, '<a href="'.$loginhelp.'">'.&mt('Login problems?').'</a>');
364: }
365: #FIXME: link to helpdesk might be added here
366:
367: $r->print(
368: $start_page
369: .'<h2>'.&mt('Sorry ...').'</h2>'
370: .&Apache::lonhtmlcommon::confirm_success(&mt($message),1).'<br /><br />'
371: .&Apache::lonhtmlcommon::actionbox(\@actions)
372: .$end_page
373: );
374: }
375:
376: # ------------------------------------------------------------------ Rerouting!
377:
378: sub reroute {
379: my ($r) = @_;
380: &Apache::loncommon::content_type($r,'text/html');
381: $r->send_http_header;
382: my $msg='<b>'.&mt('Sorry ...').'</b><br />'
383: .&mt('Please [_1]log in again[_2].');
384: &Apache::loncommon::simple_error_page($r,'Rerouting',$msg,{'no_auto_mt_msg' => 1});
385: }
386:
387: # ---------------------------------------------------------------- Main handler
388:
389: sub handler {
390: my $r = shift;
391: my $londocroot = $r->dir_config('lonDocRoot');
392: # Are we re-routing?
393: if (-e "$londocroot/lon-status/reroute.txt") {
394: &reroute($r);
395: return OK;
396: }
397:
398: &Apache::lonlocal::get_language_handle($r);
399:
400: # -------------------------------- Prevent users from attempting to login twice
401: my $handle = &Apache::lonnet::check_for_valid_session($r);
402: if ($handle ne '') {
403: my $lonidsdir=$r->dir_config('lonIDsDir');
404: if ($handle=~/^publicuser\_/) {
405: # For "public user" - remove it, we apparently really want to login
406: unlink($r->dir_config('lonIDsDir')."/$handle.id");
407: } else {
408: # Indeed, a valid token is found
409: &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
410: &Apache::loncommon::content_type($r,'text/html');
411: $r->send_http_header;
1.166 raeburn 412: my $start_page =
1.136 kruse 413: &Apache::loncommon::start_page('Already logged in');
414: my $end_page =
415: &Apache::loncommon::end_page();
416: my $dest = '/adm/roles';
1.169 ! raeburn 417: my %form = &get_form_items($r);
! 418: if ($form{'logtoken'}) {
! 419: my $tmpinfo = &Apache::lonnet::reply('tmpget:'.$form{'logtoken'},
! 420: $form{'serverid'});
! 421: unless (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost') ||
! 422: ($tmpinfo eq 'no_such_host')) {
! 423: my ($des_key,$firsturl,@rest)=split(/&/,$tmpinfo);
! 424: $firsturl = &unescape($firsturl);
! 425: my %info;
! 426: foreach my $item (@rest) {
! 427: my ($key,$value) = split(/=/,$item);
! 428: $info{$key} = &unescape($value);
! 429: }
! 430: if ($firsturl ne '') {
! 431: $info{'firsturl'} = $firsturl;
! 432: $dest = $firsturl;
! 433: my $relogin;
! 434: if ($dest =~ m{^/tiny/$match_domain/\w+$}) {
! 435: if ($env{'request.course.id'}) {
! 436: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
! 437: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
! 438: my $symb = &Apache::loncommon::symb_from_tinyurl($dest,$cnum,$cdom);
! 439: if ($symb) {
! 440: unless (&set_deeplink_login(%info) eq 'ok') {
! 441: $relogin = 1;
! 442: }
! 443: }
! 444: }
! 445: if ($relogin) {
! 446: $r->print(
! 447: $start_page
! 448: .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'
! 449: .'<p>'.&mt('Please [_1]log out[_2] first, and then try your access again',
! 450: '<a href="/adm/logout">','</a>')
! 451: .'</p>'
! 452: .$end_page);
! 453: } else {
! 454: if (($info{'linkprot'}) || ($info{'linkkey'} ne '')) {
! 455: my $token = &Apache::lonnet::tmpput(\%info,$r->dir_config('lonHostID'),'link');
! 456: unless (($token eq 'con_lost') || ($token eq 'refused') ||
! 457: ($token eq 'unknown_cmd') || ($token eq 'no_such_host')) {
! 458: $dest .= (($dest =~ /\?/) ? '&' : '?') . 'ttoken='.$token;
! 459: }
! 460: }
! 461: $r->print(
! 462: $start_page
! 463: .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'
! 464: .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4] first, and then try your access again',
! 465: '<a href="'.$dest.'">','</a>',
! 466: '<a href="/adm/logout">','</a>')
! 467: .'</p>'
! 468: .$end_page);
! 469: }
! 470: return OK;
1.164 raeburn 471: }
472: }
1.157 raeburn 473: }
1.136 kruse 474: }
475: $r->print(
1.169 ! raeburn 476: $start_page
! 477: .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'
! 478: .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].'
! 479: ,'<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>')
! 480: .'</p>'
! 481: .$end_page
1.136 kruse 482: );
483: return OK;
484: }
485: }
486:
487: # ---------------------------------------------------- No valid token, continue
488:
1.169 ! raeburn 489: my %form = &get_form_items($r);
1.136 kruse 490: if ((!$form{'uname'}) || (!$form{'upass0'}) || (!$form{'udom'})) {
491: &failed($r,'Username, password and domain need to be specified.',
492: \%form);
493: return OK;
494: }
495:
496: # split user logging in and "su"-user
497:
1.145 raeburn 498: ($form{'uname'},$form{'suname'},$form{'sudom'})=split(/\:/,$form{'uname'});
1.136 kruse 499: $form{'uname'} = &LONCAPA::clean_username($form{'uname'});
500: $form{'suname'}= &LONCAPA::clean_username($form{'suname'});
1.145 raeburn 501: $form{'udom'} = &LONCAPA::clean_domain($form{'udom'});
502: $form{'sudom'} = &LONCAPA::clean_domain($form{'sudom'});
1.136 kruse 503:
504: my $role = $r->dir_config('lonRole');
505: my $domain = $r->dir_config('lonDefDomain');
506: my $prodir = $r->dir_config('lonUsersDir');
507: my $contact_name = &mt('LON-CAPA helpdesk');
508:
509: # ---------------------------------------- Get the information from login token
510:
511: my $tmpinfo=Apache::lonnet::reply('tmpget:'.$form{'logtoken'},
512: $form{'serverid'});
513:
514: if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost') ||
515: ($tmpinfo eq 'no_such_host')) {
516: &failed($r,'Information needed to verify your login information is missing, inaccessible or expired.',\%form);
517: return OK;
518: } else {
519: my $reply = &Apache::lonnet::reply('tmpdel:'.$form{'logtoken'},
520: $form{'serverid'});
521: if ( $reply ne 'ok' ) {
522: &failed($r,'Session could not be opened.',\%form);
523: &Apache::lonnet::logthis("ERROR got a reply of $reply when trying to contact ". $form{'serverid'}." to get login token");
524: return OK;
525: }
526: }
527:
528: if (!&Apache::lonnet::domain($form{'udom'})) {
529: &failed($r,'The domain you provided is not a valid LON-CAPA domain.',\%form);
530: return OK;
531: }
532:
1.169 ! raeburn 533: my ($des_key,$firsturl,@rest)=split(/&/,$tmpinfo);
! 534: $firsturl = &unescape($firsturl);
1.168 raeburn 535: foreach my $item (@rest) {
536: my ($key,$value) = split(/=/,$item);
537: $form{$key} = &unescape($value);
1.156 raeburn 538: }
1.155 raeburn 539: if ($firsturl =~ m{^/tiny/$match_domain/\w+$}) {
540: $form{'firsturl'} = $firsturl;
541: }
1.139 raeburn 542: my $upass = $ENV{HTTPS} ? $form{'upass0'}
1.169 ! raeburn 543: : &Apache::loncommon::des_decrypt($des_key,$form{'upass0'});
1.136 kruse 544:
545: # ---------------------------------------------------------------- Authenticate
546:
547: my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$form{'udom'});
548: my ($cancreate,$statustocreate) =
549: &Apache::createaccount::get_creation_controls($form{'udom'},$domconfig{'usercreation'});
550: my $defaultauth;
551: if (ref($cancreate) eq 'ARRAY') {
552: if (grep(/^login$/,@{$cancreate})) {
553: $defaultauth = 1;
554: }
555: }
556: my $clientcancheckhost = 1;
557: my $authhost=Apache::lonnet::authenticate($form{'uname'},$upass,
558: $form{'udom'},$defaultauth,
559: $clientcancheckhost);
1.149 raeburn 560:
1.136 kruse 561: # --------------------------------------------------------------------- Failed?
562:
563: if ($authhost eq 'no_host') {
564: &failed($r,'Username and/or password could not be authenticated.',
565: \%form);
566: return OK;
567: } elsif ($authhost eq 'no_account_on_host') {
568: if ($defaultauth) {
569: my $domdesc = &Apache::lonnet::domain($form{'udom'},'description');
570: unless (&check_can_host($r,\%form,'no_account_on_host',$domdesc)) {
571: return OK;
572: }
573: my $start_page =
1.168 raeburn 574: &Apache::loncommon::start_page('Create a user account in LON-CAPA',
575: '',{'no_inline_link' => 1,});
1.136 kruse 576: my $lonhost = $r->dir_config('lonHostID');
577: my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
578: my $contacts =
579: &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
580: $form{'udom'},$origmail);
581: my ($contact_email) = split(',',$contacts);
582: my $output =
583: &Apache::createaccount::username_check($form{'uname'},$form{'udom'},
584: $domdesc,'',$lonhost,
585: $contact_email,$contact_name,
586: undef,$statustocreate);
587: &Apache::loncommon::content_type($r,'text/html');
588: $r->send_http_header;
589: &Apache::createaccount::print_header($r,$start_page);
590: $r->print('<h3>'.&mt('Account creation').'</h3>'.
591: &mt('Although your username and password were authenticated, you do not currently have a LON-CAPA account at this institution.').'<br />'.
592: $output.&Apache::loncommon::end_page());
593: return OK;
594: } else {
595: &failed($r,'Although your username and password were authenticated, you do not currently have a LON-CAPA account in this domain, and you are not permitted to create one.',\%form);
596: return OK;
597: }
598: }
599:
600: if (($firsturl eq '') ||
601: ($firsturl=~/^\/adm\/(logout|remote)/)) {
602: $firsturl='/adm/roles';
603: }
604:
1.169 ! raeburn 605: my ($hosthere,%sessiondata);
1.136 kruse 606: if ($form{'iptoken'}) {
1.169 ! raeburn 607: %sessiondata = &Apache::lonnet::tmpget($form{'iptoken'});
1.138 raeburn 608: my $delete = &Apache::lonnet::tmpdel($form{'iptoken'});
1.136 kruse 609: if (($sessiondata{'domain'} eq $form{'udom'}) &&
610: ($sessiondata{'username'} eq $form{'uname'})) {
611: $hosthere = 1;
612: }
613: }
614:
615: # --------------------------------- Are we attempting to login as somebody else?
616: if ($form{'suname'}) {
1.145 raeburn 617: my ($suname,$sudom,$sudomref);
618: $suname = $form{'suname'};
619: $sudom = $form{'udom'};
620: if ($form{'sudom'}) {
621: unless ($sudom eq $form{'sudom'}) {
622: if (&Apache::lonnet::domain($form{'sudom'})) {
623: $sudomref = [$form{'sudom'}];
624: $sudom = $form{'sudom'};
625: }
626: }
627: }
1.136 kruse 628: # ------------ see if the original user has enough privileges to pull this stunt
1.145 raeburn 629: if (&Apache::lonnet::privileged($form{'uname'},$form{'udom'},$sudomref)) {
1.136 kruse 630: # ---------------------------------------------------- see if the su-user exists
1.145 raeburn 631: unless (&Apache::lonnet::homeserver($suname,$sudom) eq 'no_host') {
1.136 kruse 632: # ------------------------------ see if the su-user is not too highly privileged
1.146 raeburn 633: if (&Apache::lonnet::privileged($suname,$sudom)) {
634: &Apache::lonnet::logthis('Attempted switch user to privileged user');
635: } else {
636: my $noprivswitch;
1.145 raeburn 637: #
638: # su-user's home server and user's home server must have one of:
1.147 raeburn 639: # (a) same domain
640: # (b) same primary library server for the two domains
641: # (c) same "internet domain" for primary library server(s) for home servers' domains
1.145 raeburn 642: #
1.148 raeburn 643: my $suprim = &Apache::lonnet::domain($sudom,'primary');
644: my $suintdom = &Apache::lonnet::internet_dom($suprim);
1.145 raeburn 645: unless ($sudom eq $form{'udom'}) {
1.148 raeburn 646: my $uprim = &Apache::lonnet::domain($form{'udom'},'primary');
647: my $uintdom = &Apache::lonnet::internet_dom($uprim);
1.145 raeburn 648: unless ($suprim eq $uprim) {
649: unless ($suintdom eq $uintdom) {
650: &Apache::lonnet::logthis('Attempted switch user '
1.169 ! raeburn 651: .'to user with different "internet domain".');
1.146 raeburn 652: $noprivswitch = 1;
1.145 raeburn 653: }
654: }
655: }
656:
1.146 raeburn 657: unless ($noprivswitch) {
658: #
659: # server where log-in occurs must have same "internet domain" as su-user's home
660: # server
661: #
662: my $lonhost = $r->dir_config('lonHostID');
663: my $hostintdom = &Apache::lonnet::internet_dom($lonhost);
1.148 raeburn 664: if ($hostintdom ne $suintdom) {
1.146 raeburn 665: &Apache::lonnet::logthis('Attempted switch user on a '
666: .'server with a different "internet domain".');
667: } else {
668:
1.136 kruse 669: # -------------------------------------------------------- actually switch users
1.145 raeburn 670:
1.146 raeburn 671: &Apache::lonnet::logperm('User '.$form{'uname'}.' at '.
672: $form{'udom'}.' logging in as '.$suname.':'.$sudom);
673: $form{'uname'}=$suname;
674: if ($form{'udom'} ne $sudom) {
675: $form{'udom'}=$sudom;
676: }
677: }
1.145 raeburn 678: }
1.136 kruse 679: }
680: }
681: } else {
682: &Apache::lonnet::logthis('Non-privileged user attempting switch user');
683: }
684: }
685:
686: my ($is_balancer,$otherserver);
687:
688: unless ($hosthere) {
689: ($is_balancer,$otherserver) =
1.141 raeburn 690: &Apache::lonnet::check_loadbalancing($form{'uname'},$form{'udom'},'login');
691: if ($is_balancer) {
1.161 raeburn 692: # Check if browser sent a LON-CAPA load balancer cookie (and this is a balancer)
693: my ($found_server,$balancer_cookie) = &Apache::lonnet::check_for_balancer_cookie($r);
694: if (($found_server) && ($balancer_cookie =~ /^\Q$env{'user.domain'}\E_\Q$env{'user.name'}\E_/)) {
695: $otherserver = $found_server;
696: }
1.141 raeburn 697: if ($otherserver eq '') {
698: my $lowest_load;
699: ($otherserver,undef,undef,undef,$lowest_load) = &Apache::lonnet::choose_server($form{'udom'});
700: if ($lowest_load > 100) {
1.163 raeburn 701: $otherserver = &Apache::lonnet::spareserver($r,$lowest_load,$lowest_load,1,$form{'udom'});
1.141 raeburn 702: }
703: }
704: if ($otherserver ne '') {
705: my @hosts = &Apache::lonnet::current_machine_ids();
706: if (grep(/^\Q$otherserver\E$/,@hosts)) {
707: $hosthere = $otherserver;
708: }
709: }
710: }
1.136 kruse 711: }
712:
1.141 raeburn 713: if (($is_balancer) && (!$hosthere)) {
1.136 kruse 714: if ($otherserver) {
715: &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef,
716: \%form);
717: my $switchto = '/adm/switchserver?otherserver='.$otherserver;
718: if (($firsturl) && ($firsturl ne '/adm/switchserver') && ($firsturl ne '/adm/roles')) {
1.168 raeburn 719: $switchto .= '&origurl='.$firsturl;
1.136 kruse 720: }
721: if ($form{'role'}) {
722: $switchto .= '&role='.$form{'role'};
723: }
724: if ($form{'symb'}) {
725: $switchto .= '&symb='.$form{'symb'};
726: }
1.156 raeburn 727: if ($form{'linkprot'}) {
728: $env{'request.linkprot'} = $form{'linkprot'};
1.167 raeburn 729: } elsif ($form{'linkkey'} ne '') {
1.164 raeburn 730: $env{'request.linkkey'} = $form{'linkkey'};
731: }
732: if ($form{'firsturl'} =~ m{^/tiny/$match_domain/\w+$}) {
733: &set_deeplink_login(%form);
1.156 raeburn 734: }
1.136 kruse 735: $r->internal_redirect($switchto);
736: } else {
1.160 raeburn 737: &Apache::loncommon::content_type($r,'text/html');
738: $r->send_http_header;
1.136 kruse 739: $r->print(&noswitch());
740: }
741: return OK;
742: } else {
743: if (!&check_can_host($r,\%form,$authhost)) {
744: my ($otherserver) = &Apache::lonnet::choose_server($form{'udom'});
745: if ($otherserver) {
746: &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef,
747: \%form);
748: my $switchto = '/adm/switchserver?otherserver='.$otherserver;
749: if (($firsturl) && ($firsturl ne '/adm/switchserver') && ($firsturl ne '/adm/roles')) {
1.168 raeburn 750: $switchto .= '&origurl='.$firsturl;
1.136 kruse 751: }
752: if ($form{'role'}) {
753: $switchto .= '&role='.$form{'role'};
754: }
755: if ($form{'symb'}) {
756: $switchto .= '&symb='.$form{'symb'};
757: }
1.156 raeburn 758: if ($form{'linkprot'}) {
759: $env{'request.linkprot'} = $form{'linkprot'};
1.167 raeburn 760: } elsif ($form{'linkkey'} ne '') {
1.164 raeburn 761: $env{'request.linkkey'} = $form{'linkkey'};
762: }
763: if ($form{'firsturl'} =~ m{^/tiny/$match_domain/\w+$}) {
764: &set_deeplink_login(%form);
1.156 raeburn 765: }
1.136 kruse 766: $r->internal_redirect($switchto);
767: } else {
1.160 raeburn 768: &Apache::loncommon::content_type($r,'text/html');
769: $r->send_http_header;
1.136 kruse 770: $r->print(&noswitch());
771: }
772: return OK;
773: }
774:
775: # ------------------------------------------------------- Do the load balancing
776:
777: # ---------------------------------------------------------- Determine own load
778: my $loadlim = $r->dir_config('lonLoadLim');
779: my $loadavg;
780: {
781: my $loadfile=Apache::File->new('/proc/loadavg');
782: $loadavg=<$loadfile>;
783: }
784: $loadavg =~ s/\s.*//g;
785: my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
786: my $userloadpercent=&Apache::lonnet::userload();
787:
788: # ---------------------------------------------------------- Are we overloaded?
789: if ((($userloadpercent>100.0)||($loadpercent>100.0))) {
1.163 raeburn 790: my $unloaded=Apache::lonnet::spareserver($r,$loadpercent,$userloadpercent,1,$form{'udom'});
1.136 kruse 791: if (!$unloaded) {
792: ($unloaded) = &Apache::lonnet::choose_server($form{'udom'});
793: }
794: if ($unloaded) {
795: &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',
796: undef,\%form);
1.156 raeburn 797: if ($form{'linkprot'}) {
798: $env{'request.linkprot'} = $form{'linkprot'};
1.167 raeburn 799: } elsif ($form{'linkkey'} ne '') {
1.164 raeburn 800: $env{'request.linkkey'} = $form{'linkkey'};
801: }
802: if ($form{'firsturl'} =~ m{^/tiny/$match_domain/\w+$}) {
803: &set_deeplink_login(%form);
1.156 raeburn 804: }
1.136 kruse 805: $r->internal_redirect('/adm/switchserver?otherserver='.$unloaded.'&origurl='.$firsturl);
806: return OK;
807: }
808: }
1.141 raeburn 809: if (($is_balancer) && ($hosthere)) {
810: $form{'noloadbalance'} = $hosthere;
811: }
1.156 raeburn 812: my $extra_env;
1.169 ! raeburn 813: if (($hosthere) && ($sessiondata{'sessionserver'} ne '')) {
! 814: if ($sessiondata{'origurl'} ne '') {
! 815: $firsturl = $sessiondata{'origurl'};
! 816: $form{'firsturl'} = $sessiondata{'origurl'};
! 817: my @names = ('role','symb','linkprot','linkkey');
! 818: foreach my $item (@names) {
! 819: if ($sessiondata{$item} ne '') {
! 820: $form{$item} = $sessiondata{$item};
! 821: }
! 822: }
! 823: }
! 824: }
1.156 raeburn 825: if ($form{'linkprot'}) {
826: my ($linkprotector,$uri) = split(/:/,$form{'linkprot'},2);
827: if ($linkprotector) {
828: $extra_env = {'user.linkprotector' => $linkprotector,
1.164 raeburn 829: 'user.linkproturi' => $uri};
1.156 raeburn 830: }
1.167 raeburn 831: } elsif ($form{'linkkey'} ne '') {
1.166 raeburn 832: $extra_env = {'user.deeplinkkey' => $form{'linkkey'},
1.164 raeburn 833: 'user.keyedlinkuri' => $form{'firsturl'}};
834: }
835: if ($form{'firsturl'} =~ m{^/tiny/$match_domain/\w+$}) {
836: &set_deeplink_login(%form);
1.166 raeburn 837: if ($form{'linkprot'}) {
838: if (ref($extra_env) eq 'HASH') {
839: %{$extra_env} = ( %{$extra_env}, 'request.linkprot' => $form{'linkprot'} );
840: } else {
841: $extra_env = {'request.linkprot' => $form{'linkprot'}};
842: }
1.167 raeburn 843: } elsif ($form{'linkkey'} ne '') {
1.166 raeburn 844: if (ref($extra_env) eq 'HASH') {
845: %{$extra_env} = ( %{$extra_env}, 'request.linkkey' => $form{'linkkey'} );
846: } else {
847: $extra_env = {'request.linkkey' => $form{'linkkey'}};
848: }
849: }
1.164 raeburn 850: if ($env{'request.deeplink.login'}) {
851: if (ref($extra_env) eq 'HASH') {
852: %{$extra_env} = ( %{$extra_env}, 'request.deeplink.login' => $form{'firsturl'} );
853: } else {
854: $extra_env = {'request.deeplink.login' => $form{'firsturl'}};
855: }
1.157 raeburn 856: }
1.156 raeburn 857: }
858: &success($r,$form{'uname'},$form{'udom'},$authhost,$firsturl,$extra_env,
1.136 kruse 859: \%form);
860: return OK;
861: }
862: }
863:
1.169 ! raeburn 864: sub get_form_items {
! 865: my ($r) = @_;
! 866: my $buffer;
! 867: if ($r->header_in('Content-length') > 0) {
! 868: $r->read($buffer,$r->header_in('Content-length'),0);
! 869: }
! 870: my %form;
! 871: foreach my $pair (split(/&/,$buffer)) {
! 872: my ($name,$value) = split(/=/,$pair);
! 873: $value =~ tr/+/ /;
! 874: $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
! 875: $form{$name}=$value;
! 876: }
! 877: return %form;
! 878: }
! 879:
1.164 raeburn 880: sub set_deeplink_login {
881: my (%form) = @_;
1.169 ! raeburn 882: my $disallow;
1.164 raeburn 883: if ($form{'firsturl'} =~ m{^/tiny/($match_domain)/\w+$}) {
884: my $cdom = $1;
885: my ($cnum,$symb) = &Apache::loncommon::symb_from_tinyurl($form{'firsturl'},'',$cdom);
886: if ($symb) {
1.166 raeburn 887: if ($env{'request.course.id'} eq $cdom.'_'.$cnum) {
1.169 ! raeburn 888: my $deeplink;
1.166 raeburn 889: if ($symb =~ /\.(page|sequence)$/) {
890: my $mapname = &Apache::lonnet::deversion((&Apache::lonnet::decode_symb($symb))[2]);
891: my $navmap = Apache::lonnavmaps::navmap->new();
892: if (ref($navmap)) {
893: $deeplink = $navmap->get_mapparam(undef,$mapname,'0.deeplink');
894: }
895: } else {
896: $deeplink = &Apache::lonnet::EXT('resource.0.deeplink',$symb);
897: }
898: if ($deeplink ne '') {
899: my ($state,$others,$listed,$scope,$protect) = split(/,/,$deeplink);
900: if (($protect ne 'none') && ($protect ne '')) {
901: my ($acctype,$item) = split(/:/,$protect);
902: if ($acctype =~ /lti(c|d)$/) {
903: unless ($form{'linkprot'} eq $item.$1.':'.$env{'request.deeplink.login'}) {
904: $disallow = 1;
905: }
906: } elsif ($acctype eq 'key') {
907: unless ($form{'linkkey'} eq $item) {
908: $disallow = 1;
909: }
1.164 raeburn 910: }
911: }
912: }
1.166 raeburn 913: unless ($disallow) {
914: $env{'request.deeplink.login'} = $form{'firsturl'};
915: }
916: } else {
1.164 raeburn 917: $env{'request.deeplink.login'} = $form{'firsturl'};
918: }
919: }
920: }
1.169 ! raeburn 921: if ($disallow) {
! 922: return;
! 923: }
! 924: return 'ok';
1.164 raeburn 925: }
926:
1.168 raeburn 927: sub set_retry_token {
928: my ($form,$lonhost,$querystr) = @_;
929: if (ref($form) eq 'HASH') {
930: my ($firsturl,$token,$extras,@names);
1.169 ! raeburn 931: @names = ('role','symb','linkprot','linkkey','iptoken');
1.168 raeburn 932: foreach my $name (@names) {
933: if ($form->{$name} ne '') {
934: $extras .= '&'.$name.'='.&escape($form->{$name});
935: last if ($name eq 'linkprot');
936: }
937: }
938: my $firsturl = $form->{'firsturl'};
939: if (($firsturl ne '') || ($extras ne '')) {
940: $extras .= ':retry';
941: $token = &Apache::lonnet::reply('tmpput:'.&escape($firsturl).
942: $extras,$lonhost);
943: if (($token eq 'con_lost') || ($token eq 'no_such_host')) {
944: return 'fail';
945: } else {
946: if (ref($querystr)) {
947: $$querystr = 'retry='.$token;
948: }
949: return 'ok';
950: }
951: }
952: }
953: return;
954: }
955:
1.136 kruse 956: sub check_can_host {
957: my ($r,$form,$authhost,$domdesc) = @_;
958: return unless (ref($form) eq 'HASH');
959: my $canhost = 1;
960: my $lonhost = $r->dir_config('lonHostID');
961: my $udom = $form->{'udom'};
962: my @intdoms;
963: my $internet_names = &Apache::lonnet::get_internet_names($lonhost);
964: if (ref($internet_names) eq 'ARRAY') {
965: @intdoms = @{$internet_names};
966: }
967: my $uprimary_id = &Apache::lonnet::domain($udom,'primary');
968: my $uint_dom = &Apache::lonnet::internet_dom($uprimary_id);
969: unless ($uint_dom ne '' && grep(/^\Q$uint_dom\E$/,@intdoms)) {
970: my $machine_dom = &Apache::lonnet::host_domain($lonhost);
971: my $hostname = &Apache::lonnet::hostname($lonhost);
972: my $serverhomeID = &Apache::lonnet::get_server_homeID($hostname);
973: my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID);
974: my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom);
975: my %udomdefaults = &Apache::lonnet::get_domain_defaults($udom);
976: my $loncaparev;
977: if ($authhost eq 'no_account_on_host') {
978: $loncaparev = &Apache::lonnet::get_server_loncaparev($machine_dom);
979: } else {
980: $loncaparev = &Apache::lonnet::get_server_loncaparev($machine_dom,$lonhost);
981: }
982: $canhost = &Apache::lonnet::can_host_session($udom,$lonhost,$loncaparev,
983: $udomdefaults{'remotesessions'},
984: $defdomdefaults{'hostedsessions'});
985: }
986: unless ($canhost) {
987: if ($authhost eq 'no_account_on_host') {
988: my $checkloginvia = 1;
989: my ($login_host,$hostname) =
990: &Apache::lonnet::choose_server($udom,$checkloginvia);
991: &Apache::loncommon::content_type($r,'text/html');
992: $r->send_http_header;
993: if ($login_host ne '') {
994: my $protocol = $Apache::lonnet::protocol{$login_host};
995: $protocol = 'http' if ($protocol ne 'https');
1.163 raeburn 996: my $alias = &Apache::lonnet::use_proxy_alias($r,$login_host);
997: $hostname = $alias if ($alias ne '');
1.136 kruse 998: my $newurl = $protocol.'://'.$hostname.'/adm/createaccount';
1.156 raeburn 999: #FIXME Should preserve where user was going and linkprot by setting ltoken at $login_host
1.136 kruse 1000: $r->print(&Apache::loncommon::start_page('Create a user account in LON-CAPA').
1001: '<h3>'.&mt('Account creation').'</h3>'.
1002: &mt('You do not currently have a LON-CAPA account at this institution.').'<br />'.
1003: '<p>'.&mt('You will be able to create one by logging into a LON-CAPA server within the [_1] domain.',$domdesc).'</p>'.
1004: '<p>'.&mt('[_1]Log in[_2]','<a href="'.$newurl.'">','</a>').
1005: &Apache::loncommon::end_page());
1006: } else {
1007: $r->print(&Apache::loncommon::start_page('Access to LON-CAPA unavailable').
1008: '<h3>'.&mt('Account creation unavailable').'</h3>'.
1009: &mt('You do not currently have a LON-CAPA account at this institution.').'<br />'.
1010: '<p>'.&mt('Currently a LON-CAPA server is not available within the [_1] domain for you to log-in to, to create an account.',$domdesc).'</p>'.
1011: &Apache::loncommon::end_page());
1012: }
1013: } else {
1014: &success($r,$form->{'uname'},$udom,$authhost,'noredirect',undef,
1015: $form);
1.168 raeburn 1016: if ($form->{'firsturl'} =~ m{^/tiny/$match_domain/\w+$}) {
1017: $env{'request.deeplink.login'} = $form->{'firsturl'};
1018: }
1.156 raeburn 1019: if ($form->{'linkprot'}) {
1020: $env{'request.linkprot'} = $form->{'linkprot'};
1.168 raeburn 1021: } elsif ($form->{'linkkey'} ne '') {
1022: $env{'request.linkkey'} = $form->{'linkkey'};
1.156 raeburn 1023: }
1.136 kruse 1024: my ($otherserver) = &Apache::lonnet::choose_server($udom);
1025: $r->internal_redirect('/adm/switchserver?otherserver='.$otherserver);
1026: }
1027: }
1028: return $canhost;
1029: }
1030:
1031: sub noswitch {
1032: my $result = &Apache::loncommon::start_page('Access to LON-CAPA unavailable').
1033: '<h3>'.&mt('Session unavailable').'</h3>'.
1034: &mt('This LON-CAPA server is unable to host your session.').'<br />'.
1035: '<p>'.&mt('Currently no other LON-CAPA server is available to host your session either.').'</p>'.
1036: &Apache::loncommon::end_page();
1037: return $result;
1038: }
1039:
1040: sub loginhelpdisplay {
1041: my ($authdomain) = @_;
1042: my $login_help = 1;
1043: my $lang = &Apache::lonlocal::current_language();
1044: if ($login_help) {
1045: my $dom = $authdomain;
1046: if ($dom eq '') {
1047: $dom = &Apache::lonnet::default_login_domain();
1048: }
1049: my %domconfhash = &Apache::loncommon::get_domainconf($dom);
1050: my $loginhelp_url;
1051: if ($lang) {
1052: $loginhelp_url = $domconfhash{$dom.'.login.helpurl_'.$lang};
1053: if ($loginhelp_url ne '') {
1054: return $loginhelp_url;
1055: }
1056: }
1057: $loginhelp_url = $domconfhash{$dom.'.login.helpurl_nolang'};
1058: if ($loginhelp_url ne '') {
1059: return $loginhelp_url;
1060: } else {
1061: return '/adm/loginproblems.html';
1062: }
1063: }
1064: return;
1065: }
1066:
1067: 1;
1068: __END__
1069:
1070:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>