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

raeburn raeburn@source.lon-capa.org
Wed, 17 Mar 2010 14:37:43 -0000


raeburn		Wed Mar 17 14:37:43 2010 EDT

  Modified files:              
    /loncom/auth	lonlogin.pm 
  Log:
  - If custom log-in help page, link to page for domain displayed in domain textbox (may be different from default_login_domain.
  - If user is already logged in, load user's %env so primary_menu links  are shown for user.  
    - Don't display "login problems" link, if user is already logged in,
      as it doesn't make sense here.
  
  
Index: loncom/auth/lonlogin.pm
diff -u loncom/auth/lonlogin.pm:1.134 loncom/auth/lonlogin.pm:1.135
--- loncom/auth/lonlogin.pm:1.134	Wed Mar  3 17:05:49 2010
+++ loncom/auth/lonlogin.pm	Wed Mar 17 14:37:43 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Login Screen
 #
-# $Id: lonlogin.pm,v 1.134 2010/03/03 17:05:49 raeburn Exp $
+# $Id: lonlogin.pm,v 1.135 2010/03/17 14:37:43 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -72,36 +72,31 @@
 
 # -------------------------------- Prevent users from attempting to login twice
     my $handle = &Apache::lonnet::check_for_valid_session($r);
-    if ($handle=~/^publicuser\_/) {
+    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");
-    } elsif ($handle ne '') {
+	    unlink($r->dir_config('lonIDsDir')."/$handle.id");
+        } else {
 # Indeed, a valid token is found
-	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'}; 
-        }
-        
-    my $dom = &Apache::lonnet::default_login_domain();
-    my %helpconfig = &Apache::lonnet::get_dom('configuration',['helpsettings'],$dom);
-    
-    my $loginhelp_page = $helpconfig{'helpsettings'}{'loginhelpurl'};
-    if ($loginhelp_page eq '') {
-		$loginhelp_page = '/adm/loginproblems.html';
-    }
-	$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
                  .'<h1>'.&mt('You are already logged in!').'</h1>'
                  .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',
                   '<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'
-                 .'<p><a href="'.$loginhelp_page.'">'.&mt('Login problems?').'</a></p>'
-                 .$dom.' '.$end_page
+                 .$end_page
                  );
-        return OK;
+            return OK;
+        }
     }
 
 # ---------------------------------------------------- No valid token, continue
@@ -361,7 +356,7 @@
 
 my $forgotpw = &forgotpwdisplay(%lt);
 $forgotpw .= '<br />' if $forgotpw;
-my $loginhelp = &loginhelpdisplay(%lt);
+my $loginhelp = &loginhelpdisplay($authdomain,%lt);
 $loginhelp .= '<br />' if $loginhelp;
 
 # ---------------------------------------------------- Serve out DES JavaScript
@@ -626,17 +621,20 @@
 }
 
 sub loginhelpdisplay {
-    my (%lt) = @_;
+    my ($authdomain,%lt) = @_;
     my $login_help = 1;
     if ($login_help) {
-    	my $dom = &Apache::lonnet::default_login_domain();
-		my %helpconfig = &Apache::lonnet::get_dom('configuration',['helpsettings'],$dom);
-		my $loginhelp_url = $helpconfig{'helpsettings'}{'loginhelpurl'};
-		if ($loginhelp_url ne '') {
-        	return '<a href="'.$loginhelp_url.'">'.$lt{'help'}.'</a>';
+        my $dom = $authdomain;
+        if ($dom eq '') {
+            $dom = &Apache::lonnet::default_login_domain();
+        }
+        my %helpconfig = &Apache::lonnet::get_dom('configuration',['helpsettings'],$dom);
+        my $loginhelp_url = $helpconfig{'helpsettings'}{'loginhelpurl'};
+        if ($loginhelp_url ne '') {
+            return '<a href="'.$loginhelp_url.'">'.$lt{'help'}.'</a>';
         } else {
-        	return '<a href="/adm/loginproblems.html">'.$lt{'help'}.'</a>';
-       	}
+            return '<a href="/adm/loginproblems.html">'.$lt{'help'}.'</a>';
+        }
     }
     return;
 }