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

raeburn raeburn@source.lon-capa.org
Thu, 23 Sep 2010 23:47:33 -0000


raeburn		Thu Sep 23 23:47:33 2010 EDT

  Modified files:              
    /loncom/auth	lonauth.pm 
  Log:
  - Coding style for readability.
    - Move return OK to main handler.
    - Need return OK after $r->internal_redirect in main handler.
    - &check_can_host() returns 0 or 1 (1 if canhost).
  
  
Index: loncom/auth/lonauth.pm
diff -u loncom/auth/lonauth.pm:1.109 loncom/auth/lonauth.pm:1.110
--- loncom/auth/lonauth.pm:1.109	Wed Aug 25 16:34:32 2010
+++ loncom/auth/lonauth.pm	Thu Sep 23 23:47:33 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # User Authentication Module
 #
-# $Id: lonauth.pm,v 1.109 2010/08/25 16:34:32 raeburn Exp $
+# $Id: lonauth.pm,v 1.110 2010/09/23 23:47:33 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -352,7 +352,9 @@
             &Apache::lonnet::get_dom('configuration',['usercreation'],$form{'udom'});
         if (grep(/^login$/,@cancreate)) {
             my $domdesc = &Apache::lonnet::domain($form{'udom'},'description');
-            &check_can_host($r,\%form,'no_account_on_host',$domdesc);
+            unless (&check_can_host($r,\%form,'no_account_on_host',$domdesc)) {
+                return OK;
+            }
             my $start_page = 
                 &Apache::loncommon::start_page('Create a user account in LON-CAPA');
             my $lonhost = $r->dir_config('lonHostID');
@@ -404,13 +406,16 @@
 	}
     }
 
-    &check_can_host($r,\%form,$authhost);
+    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::choose_server($form{'udom'});
 	$r->internal_redirect('/adm/switchserver?otherserver='.$otherserver.'&origurl='.$firsturl);
+        return OK;
     } else {
 # ------------------------------------------------------- Do the load balancing
 
@@ -432,12 +437,13 @@
                 &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',
                          undef,\%form);
                 $r->internal_redirect('/adm/switchserver?otherserver='.$unloaded.'&origurl='.$firsturl);
+                return OK;
             }
         }
         &success($r,$form{'uname'},$form{'udom'},$authhost,$firsturl,undef,
                  \%form);
+        return OK;
     }
-    return OK;
 }
 
 sub check_can_host {
@@ -492,7 +498,6 @@
                           '<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>'.
                           &Apache::loncommon::end_page());
             }
-            return OK;
         } else {
             &success($r,$form->{'uname'},$udom,$authhost,'noredirect',undef,
                      $form);
@@ -500,6 +505,7 @@
             $r->internal_redirect('/adm/switchserver?otherserver='.$otherserver);
         }
     }
+    return $canhost;
 }
 
 1;