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

raeburn raeburn at source.lon-capa.org
Tue Nov 16 19:44:47 EST 2021


raeburn		Wed Nov 17 00:44:47 2021 EDT

  Modified files:              
    /loncom/auth	migrateuser.pm lonauth.pm 
  Log:
  - Expire any existing public cookie (and session) when establishing a session 
    for a migrated user.
  
  
Index: loncom/auth/migrateuser.pm
diff -u loncom/auth/migrateuser.pm:1.54 loncom/auth/migrateuser.pm:1.55
--- loncom/auth/migrateuser.pm:1.54	Wed Nov  3 01:04:02 2021
+++ loncom/auth/migrateuser.pm	Wed Nov 17 00:44:47 2021
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Starts a user off based of an existing token.
 #
-# $Id: migrateuser.pm,v 1.54 2021/11/03 01:04:02 raeburn Exp $
+# $Id: migrateuser.pm,v 1.55 2021/11/17 00:44:47 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -703,7 +703,20 @@
             }
         }
     } else {
-	my $handle = &Apache::lonnet::check_for_valid_session($r);
+        my ($handle,$expirepub);
+        $handle = &Apache::lonnet::check_for_valid_session($r);
+
+# For "public user" - remove any exising "public" cookie so actual user is ogged in.
+        if ($handle) {
+            if ($handle=~/^publicuser\_/) {
+                my $lonidsdir=$r->dir_config('lonIDsDir');
+                if ($lonidsdir ne '') {
+                    unlink("$lonidsdir/$handle.id");
+                }
+                undef($handle);
+                $expirepub = 1;
+            }
+        }
 	if ($handle) {
 	    &Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'),
 						     $handle);
@@ -945,7 +958,8 @@
                 }
             }
 	    &Apache::lonauth::success($r,$data{'username'},$data{'domain'},
-				      $home,$desturl,$extra_env,\%form,$skipcritical);
+				      $home,$desturl,$extra_env,\%form,$skipcritical,'',
+                                      $expirepub);
 	}
 	return OK;
     }
Index: loncom/auth/lonauth.pm
diff -u loncom/auth/lonauth.pm:1.169 loncom/auth/lonauth.pm:1.170
--- loncom/auth/lonauth.pm:1.169	Wed Nov  3 01:04:02 2021
+++ loncom/auth/lonauth.pm	Wed Nov 17 00:44:47 2021
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # User Authentication Module
 #
-# $Id: lonauth.pm,v 1.169 2021/11/03 01:04:02 raeburn Exp $
+# $Id: lonauth.pm,v 1.170 2021/11/17 00:44:47 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -42,11 +42,12 @@
 use Apache::File();
 use HTML::Entities;
 use Digest::MD5;
+use CGI::Cookie();
  
 # ------------------------------------------------------------ Successful login
 sub success {
     my ($r, $username, $domain, $authhost, $lowerurl, $extra_env,
-	$form,$skipcritical,$cid) = @_;
+	$form,$skipcritical,$cid,$expirepub) = @_;
 
 # ------------------------------------------------------------ Get cookie ready
     my $cookie =
@@ -233,6 +234,12 @@
     if ($defaultcookie) {
         $r->headers_out->add('Set-cookie' => $defaultcookie);
     }
+    if ($expirepub) {
+        my $c = new CGI::Cookie(-name    => 'lonPubID',
+                                -value   => '',
+                                -expires => '-10y',);
+        $r->headers_out->add('Set-cookie' => $c);
+    }
     $r->send_http_header;
 
     my ($start_page,$js,$pagebody,$end_page);




More information about the LON-CAPA-cvs mailing list