--- loncom/auth/lonauth.pm 2006/06/02 20:22:26 1.78 +++ loncom/auth/lonauth.pm 2006/08/30 16:50:23 1.81 @@ -1,7 +1,7 @@ # The LearningOnline Network # User Authentication Module # -# $Id: lonauth.pm,v 1.78 2006/06/02 20:22:26 albertel Exp $ +# $Id: lonauth.pm,v 1.81 2006/08/30 16:50:23 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -46,7 +46,7 @@ my %FORM; # ------------------------------------------------------------ Successful login sub success { - my ($r, $username, $domain, $authhost,$lowerurl) = @_; + my ($r, $username, $domain, $authhost, $lowerurl, $extra_env) = @_; my $lonids=$r->dir_config('lonIDsDir'); my $public=($username eq 'public' && $domain eq 'public'); @@ -88,7 +88,7 @@ sub success { # Initialize roles - $userroles=Apache::lonnet::rolesinit($domain,$username,$authhost); + $userroles=&Apache::lonnet::rolesinit($domain,$username,$authhost); } # ------------------------------------ Check browser type and MathML capability @@ -170,6 +170,7 @@ sub success { } } + $env{'user.environment'} = "$lonids/$cookie.id"; open(my $idf,">$lonids/$cookie.id"); unless (flock($idf,LOCK_EX)) { &Apache::lonnet::logthis("WARNING: ". @@ -178,13 +179,10 @@ sub success { return 'error: '.$!; } - while (my ($key,$value) = each(%initial_env)) { - print $idf (&escape($key).'='.&escape($value)."\n"); - } - while (my ($key,$value) = each(%userenv)) { - print $idf (&escape($key).'='.&escape($value)."\n"); - } - if ($userroles ne '') { print $idf "$userroles"; } + &add_to_env($idf,\%initial_env); + &add_to_env($idf,\%userenv); + &add_to_env($idf,$userroles); + &add_to_env($idf,$extra_env); close($idf); } $env{'request.role'}='cm'; @@ -251,6 +249,14 @@ $end_page ENDSUCCESS } +sub add_to_env { + my ($idf,$env_data) = @_; + @env{keys(%$env_data)} = @$env_data{keys(%$env_data)}; + while (my ($key,$value) = each(%$env_data)) { + print $idf (&escape($key).'='.&escape($value)."\n"); + } +} + # --------------------------------------------------------------- Failed login! sub failed { @@ -444,7 +450,12 @@ ENDFAILED &Apache::lonnet::logthis('Non-privileged user attempting switch user'); } } - &success($r,$FORM{'uname'},$FORM{'udom'},$authhost,$firsturl); + if ($r->dir_config("lonBalancer") eq 'yes') { + &success($r,$FORM{'uname'},$FORM{'udom'},$authhost,'noredirect'); + $r->internal_redirect('/adm/switchserver'); + } else { + &success($r,$FORM{'uname'},$FORM{'udom'},$authhost,$firsturl); + } return OK; }