--- loncom/auth/lonauth.pm 2011/02/24 23:37:50 1.111 +++ loncom/auth/lonauth.pm 2011/08/17 03:52:36 1.118 @@ -1,7 +1,7 @@ # The LearningOnline Network # User Authentication Module # -# $Id: lonauth.pm,v 1.111 2011/02/24 23:37:50 raeburn Exp $ +# $Id: lonauth.pm,v 1.118 2011/08/17 03:52:36 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -138,15 +138,15 @@ sub success { my %lt=&Apache::lonlocal::texthash( 'wel' => 'Welcome', - 'mes' => 'Welcome to the LearningOnline Network with CAPA. Please wait while your session is being set up.', 'pro' => 'Login problems?', 'log' => 'loginproblems.html', ); + my $welcome = &mt('Welcome to the Learning[_1]Online[_2] Network with CAPA. Please wait while your session is being set up.','',''); $r->print(<$lt{'wel'} -$lt{'mes'}

+$welcome

$lt{'pro'}

$continuelink $end_page @@ -274,7 +274,8 @@ sub handler { my $tmpinfo=Apache::lonnet::reply('tmpget:'.$form{'logtoken'}, $form{'serverid'}); - if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) { + if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost') || + ($tmpinfo eq 'no_such_host')) { &failed($r,'Information needed to verify your login information is missing, inaccessible or expired.',\%form); return OK; } else { @@ -414,17 +415,34 @@ sub handler { } } - unless (&check_can_host($r,\%form,$authhost)) { - return OK; - } + my ($is_balancer,$otherserver) = + &Apache::lonnet::check_loadbalancing($form{'uname'},$form{'udom'}); - if ($r->dir_config("lonBalancer") eq 'yes') { - &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef, - \%form); - my ($otherserver) = &Apache::lonnet::choose_server($form{'udom'}); - $r->internal_redirect('/adm/switchserver?otherserver='.$otherserver.'&origurl='.$firsturl); + if ($is_balancer) { + if (!$otherserver) { + ($otherserver) = &Apache::lonnet::choose_server($form{'udom'}); + } + if ($otherserver) { + &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef, + \%form); + $r->internal_redirect('/adm/switchserver?otherserver='.$otherserver.'&origurl='.$firsturl); + } else { + $r->print(&noswitch()); + } return OK; } else { + if (!&check_can_host($r,\%form,$authhost)) { + my ($otherserver) = &Apache::lonnet::choose_server($form{'udom'}); + if ($otherserver) { + &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef, + \%form); + $r->internal_redirect('/adm/switchserver?otherserver='.$otherserver.'&origurl='.$firsturl); + } else { + $r->print(&noswitch()); + } + return OK; + } + # ------------------------------------------------------- Do the load balancing # ---------------------------------------------------------- Determine own load @@ -441,6 +459,9 @@ sub handler { # ---------------------------------------------------------- Are we overloaded? if ((($userloadpercent>100.0)||($loadpercent>100.0))) { my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent,1,$form{'udom'}); + if (!$unloaded) { + ($unloaded) = &Apache::lonnet::choose_server($form{'udom'}); + } if ($unloaded) { &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect', undef,\%form); @@ -486,7 +507,9 @@ sub check_can_host { } unless ($canhost) { if ($authhost eq 'no_account_on_host') { - my ($login_host,$hostname) = &Apache::lonnet::choose_server($udom); + my $checkloginvia = 1; + my ($login_host,$hostname) = + &Apache::lonnet::choose_server($udom,$checkloginvia); &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; if ($login_host ne '') { @@ -516,6 +539,15 @@ sub check_can_host { return $canhost; } +sub noswitch { + my $result = &Apache::loncommon::start_page('Access to LON-CAPA unavailable'). + '

'.&mt('Session unavailable').'

'. + &mt('This LON-CAPA server is unable to host your session.').'
'. + '

'.&mt('Currently no other LON-CAPA server is available to host your session either.').'

'. + &Apache::loncommon::end_page(); + return $result; +} + 1; __END__