--- loncom/auth/lonlogin.pm 2007/10/09 16:48:51 1.94.2.1 +++ loncom/auth/lonlogin.pm 2007/10/01 21:52:50 1.95 @@ -1,7 +1,7 @@ # The LearningOnline Network # Login Screen # -# $Id: lonlogin.pm,v 1.94.2.1 2007/10/09 16:48:51 albertel Exp $ +# $Id: lonlogin.pm,v 1.95 2007/10/01 21:52:50 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -69,24 +69,17 @@ sub handler { # -------------------------------- Prevent users from attempting to login twice - my %cookies=CGI::Cookie->parse($r->header_in('Cookie')); - my $lonid=$cookies{'lonID'}; - my $cookie; - if ($lonid) { - my $handle=&LONCAPA::clean_handle($lonid->value); - my $lonidsdir=$r->dir_config('lonIDsDir'); - if (-e "$lonidsdir/$handle.id") { -# Is there an existing token file? - if ($handle=~/^publicuser\_/) { + my $handle = &Apache::lonnet::check_for_valid_session($r); + if ($handle=~/^publicuser\_/) { # For "public user" - remove it, we apparently really want to login - unlink("$lonidsdir/$handle.id"); - } elsif ($handle ne '') { + unlink($r->dir_config('lonIDsDir')."/$handle.id"); + } elsif ($handle ne '') { # Indeed, a valid token is found - my $start_page = - &Apache::loncommon::start_page('Already logged in'); - my $end_page = - &Apache::loncommon::end_page(); - $r->print(<print(<You are already logged in

Please either continue the current session or @@ -95,9 +88,7 @@ $start_page Problems?

$end_page ENDFAILED - return OK; - } - } + return OK; } # ---------------------------------------------------- No valid token, continue @@ -158,8 +149,9 @@ ENDFAILED my $otherserver= &Apache::lonnet::absolute_url($host_name); my $firsturl= ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'}); -# ---------------------------------------------------------- Are we overloaded? - if ((($userloadpercent>100.0)||($loadpercent>100.0))) { +# ---------------------------------------- Are we access server and overloaded? + if (($role eq 'access') && + (($userloadpercent>100.0)||($loadpercent>100.0))) { my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent); if ($unloaded) { $otherserver=$unloaded; } }