[LON-CAPA-cvs] cvs: loncom(version_2_10_X) /auth lonauth.pm

raeburn raeburn at source.lon-capa.org
Tue Sep 27 16:18:45 EDT 2011


raeburn		Tue Sep 27 20:18:45 2011 EDT

  Modified files:              (Branch: version_2_10_X)
    /loncom/auth	lonauth.pm 
  Log:
  - Backport 1.114, 1.115, 1.116, 1.118.
  
  
Index: loncom/auth/lonauth.pm
diff -u loncom/auth/lonauth.pm:1.101.8.6 loncom/auth/lonauth.pm:1.101.8.7
--- loncom/auth/lonauth.pm:1.101.8.6	Fri Jun 10 01:30:33 2011
+++ loncom/auth/lonauth.pm	Tue Sep 27 20:18:45 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # User Authentication Module
 #
-# $Id: lonauth.pm,v 1.101.8.6 2011/06/10 01:30:33 raeburn Exp $
+# $Id: lonauth.pm,v 1.101.8.7 2011/09/27 20:18:45 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -276,7 +276,8 @@
     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 {
@@ -417,17 +418,31 @@
 	}
     }
 
-    unless (&check_can_host($r,\%form,$authhost)) {
-        return OK;
-    }
-
     if ($r->dir_config("lonBalancer") eq 'yes') {
-	&success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef,
-		 \%form);
         my $otherserver = &Apache::lonnet::spareserver(30000,undef,1,$form{'udom'});
-	$r->internal_redirect('/adm/switchserver?otherserver='.$otherserver.'&origurl='.$firsturl);
+        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
@@ -444,6 +459,9 @@
 # ---------------------------------------------------------- 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);
@@ -489,7 +507,9 @@
     }
     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 '') {
@@ -519,6 +539,15 @@
     return $canhost;
 }
 
+sub noswitch {
+    my $result = &Apache::loncommon::start_page('Access to LON-CAPA unavailable').
+                 '<h3>'.&mt('Session unavailable').'</h3>'.
+                 &mt('This LON-CAPA server is unable to host your session.').'<br />'.
+                 '<p>'.&mt('Currently no other LON-CAPA server is available to host your session either.').'</p>'.
+                 &Apache::loncommon::end_page();
+    return $result;
+}
+
 1;
 __END__
 




More information about the LON-CAPA-cvs mailing list