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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 12 Oct 2006 18:18:01 -0000


albertel		Thu Oct 12 14:18:01 2006 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
    /loncom/auth	lonauth.pm 
  Log:
  - add explict ability for robot logins that don't kill actual user sessions
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.462 loncom/interface/loncommon.pm:1.463
--- loncom/interface/loncommon.pm:1.462	Tue Oct 10 17:57:31 2006
+++ loncom/interface/loncommon.pm	Thu Oct 12 14:17:57 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.462 2006/10/10 21:57:31 albertel Exp $
+# $Id: loncommon.pm,v 1.463 2006/10/12 18:17:57 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2596,7 +2596,7 @@
     my ($text,$uname,$udom,$symb,$target)=@_;
     if (!($uname && $udom)) {
 	(my $cursymb, my $courseid,$udom,$uname)=
-	    &Apache::lonxml::whichuser($symb);
+	    &Apache::lonnet::whichuser($symb);
 	if (!$symb) { $symb=$cursymb; }
     }
     if (!$symb) { $symb=&Apache::lonnet::symbread(); }
@@ -2642,7 +2642,7 @@
     my ($text,$uname,$udom,$symb,$target)=@_;
     if (!($uname && $udom)) {
 	(my $cursymb, my $courseid,$udom,$uname)=
-	    &Apache::lonxml::whichuser($symb);
+	    &Apache::lonnet::whichuser($symb);
 	if (!$symb) { $symb=$cursymb; }
     }
     if (!$symb) { $symb=&Apache::lonnet::symbread(); }
@@ -6004,7 +6004,7 @@
 
 # -------------------------------------------------------- Initliaze user login
 sub init_user_environment {
-    my ($r, $username, $domain, $authhost, $form, $extra_env) = @_;
+    my ($r, $username, $domain, $authhost, $form, $args) = @_;
     my $lonids=$Apache::lonnet::perlvar{'lonIDsDir'};
 
     my $public=($username eq 'public' && $domain eq 'public');
@@ -6032,17 +6032,20 @@
 	}
 	if (!$cookie) { $cookie="publicuser_$oldest"; }
     } else {
-	opendir(DIR,$lonids);
-	while ($filename=readdir(DIR)) {
-	    if ($filename=~/^$username\_\d+\_$domain\_$authhost\.id$/) {
-		unlink($lonids.'/'.$filename);
+	# if this isn't a robot, kill any existing non-robot sessions
+	if (!$args->{'robot'}) {
+	    opendir(DIR,$lonids);
+	    while ($filename=readdir(DIR)) {
+		if ($filename=~/^$username\_\d+\_$domain\_$authhost\.id$/) {
+		    unlink($lonids.'/'.$filename);
+		}
 	    }
+	    closedir(DIR);
 	}
-	closedir(DIR);
-
 # Give them a new cookie
-
-	$cookie="$username\_$now\_$domain\_$authhost";
+	my $id = ($args->{'robot'} ? 'robot'.$args->{'robot'}
+		                   : $now);
+	$cookie="$username\_$id\_$domain\_$authhost";
     
 # Initialize roles
 
@@ -6136,7 +6139,9 @@
 	    &_add_to_env(\%disk_env,\%initial_env);
 	    &_add_to_env(\%disk_env,\%userenv,'environment.');
 	    &_add_to_env(\%disk_env,$userroles);
-	    &_add_to_env(\%disk_env,$extra_env);
+	    if (ref($args->{'extra_env'})) {
+		&_add_to_env(\%disk_env,$args->{'extra_env'});
+	    }
 	    untie(%disk_env);
 	} else {
 	    &Apache::lonnet::logthis("<font color=\"blue\">WARNING: ".
Index: loncom/auth/lonauth.pm
diff -u loncom/auth/lonauth.pm:1.85 loncom/auth/lonauth.pm:1.86
--- loncom/auth/lonauth.pm:1.85	Tue Oct 10 17:57:12 2006
+++ loncom/auth/lonauth.pm	Thu Oct 12 14:18:01 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # User Authentication Module
 #
-# $Id: lonauth.pm,v 1.85 2006/10/10 21:57:12 albertel Exp $
+# $Id: lonauth.pm,v 1.86 2006/10/12 18:18:01 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -50,7 +50,7 @@
     my $cookie =
 	&Apache::loncommon::init_user_environment($r, $username, $domain,
 						  $authhost, $form,
-						  $extra_env);
+						  {'extra_env' => $extra_env,});
 
     my $public=($username eq 'public' && $domain eq 'public');