--- loncom/auth/lonlogin.pm 2016/04/19 18:09:11 1.166 +++ loncom/auth/lonlogin.pm 2017/02/25 19:56:09 1.170 @@ -1,7 +1,7 @@ # The LearningOnline Network # Login Screen # -# $Id: lonlogin.pm,v 1.166 2016/04/19 18:09:11 raeburn Exp $ +# $Id: lonlogin.pm,v 1.170 2017/02/25 19:56:09 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -38,6 +38,7 @@ use Apache::lonlocal; use Apache::migrateuser(); use lib '/home/httpd/lib/perl/'; use LONCAPA; +use CGI::Cookie(); sub handler { my $r = shift; @@ -56,9 +57,29 @@ sub handler { return &Apache::migrateuser::handler($r); } +# For "public user" - remove any exising "public" cookie, as user really wants to log-in + my ($handle,$lonidsdir,$expire); + unless ($r->header_only) { + $handle = &Apache::lonnet::check_for_valid_session($r); + if ($handle ne '') { + $lonidsdir=$r->dir_config('lonIDsDir'); + if ($handle=~/^publicuser\_/) { + unlink($r->dir_config('lonIDsDir')."/$handle.id"); + undef($handle); + $expire = 1; + } + } + } + &Apache::loncommon::no_cache($r); &Apache::lonlocal::get_language_handle($r); &Apache::loncommon::content_type($r,'text/html'); + if ($expire) { + my $c = new CGI::Cookie(-name => 'lonPubID', + -value => '', + -expires => '-10y',); + $r->header_out('Set-cookie' => $c); + } $r->send_http_header; return OK if $r->header_only; @@ -73,32 +94,24 @@ sub handler { $env{'form.firsturl'} =~ s/(`)/'/g; # -------------------------------- Prevent users from attempting to login twice - my $handle = &Apache::lonnet::check_for_valid_session($r); if ($handle ne '') { - my $lonidsdir=$r->dir_config('lonIDsDir'); - if ($handle=~/^publicuser\_/) { -# For "public user" - remove it, we apparently really want to login - unlink($r->dir_config('lonIDsDir')."/$handle.id"); - } else { -# Indeed, a valid token is found - &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle); - my $start_page = - &Apache::loncommon::start_page('Already logged in'); - my $end_page = - &Apache::loncommon::end_page(); - my $dest = '/adm/roles'; - if ($env{'form.firsturl'} ne '') { - $dest = $env{'form.firsturl'}; - } - $r->print( + &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle); + my $start_page = + &Apache::loncommon::start_page('Already logged in'); + my $end_page = + &Apache::loncommon::end_page(); + my $dest = '/adm/roles'; + if ($env{'form.firsturl'} ne '') { + $dest = $env{'form.firsturl'}; + } + $r->print( $start_page .'

'.&mt('You are already logged in!').'

' .'

'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].', '','','','').'

' .$end_page ); - return OK; - } + return OK; } # ---------------------------------------------------- No valid token, continue @@ -358,6 +371,7 @@ if(this.document.server.action.substr(0, } else { this.document.server.elements.upass0.value =this.document.client.elements.upass$now.value; +} this.document.client.elements.uname.value=''; this.document.client.elements.upass$now.value=''; @@ -522,7 +536,7 @@ LFORM $r->print(<
- The Learning Online Network with CAPA + The Learning Online Network with CAPA
HEADER } @@ -546,7 +560,7 @@ HEADER
ENDTOP if ($showmainlogo) { - $r->print(' '."\n"); + $r->print(' '."\n"); } $r->print(<