[LON-CAPA-cvs] cvs: loncom /interface createaccount.pm

raeburn raeburn at source.lon-capa.org
Fri May 18 00:31:05 EDT 2012


raeburn		Fri May 18 04:31:05 2012 EDT

  Modified files:              
    /loncom/interface	createaccount.pm 
  Log:
  - Changes to: &create_account() third arg: $lonhost eliminated (not used).
    - now returns third item - $uhome (lonHostID of new user's home server).
  - Changes to calls to &start_session() - fourth arg is now $uhome 
    (lonHostID of new user's home server) instead of lonHostID of server 
    hosting session.
  - Changes to calls to &Apache::lonauth::success() pass $uhome as fourth arg
    instead of $lonhost.
  
  
Index: loncom/interface/createaccount.pm
diff -u loncom/interface/createaccount.pm:1.50 loncom/interface/createaccount.pm:1.51
--- loncom/interface/createaccount.pm:1.50	Thu May 17 18:05:42 2012
+++ loncom/interface/createaccount.pm	Fri May 18 04:31:05 2012
@@ -3,7 +3,7 @@
 # institutional log-in ID (institutional authentication required - localauth
 #  or kerberos) or an e-mail address.
 #
-# $Id: createaccount.pm,v 1.50 2012/05/17 18:05:42 www Exp $
+# $Id: createaccount.pm,v 1.51 2012/05/18 04:31:05 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -121,16 +121,14 @@
             &print_footer($r);
             return OK;
         } else {
-            $start_page = 
-                &Apache::loncommon::start_page($title,$js);
+            $start_page = &Apache::loncommon::start_page($title,$js); 
             &print_header($r,$start_page,$courseid);
             $r->print($output);
             &print_footer($r);    
             return OK;
         }
     }
-    $start_page =
-        &Apache::loncommon::start_page($title,$js);
+    $start_page = &Apache::loncommon::start_page($title,$js);
 
     my %domconfig = 
         &Apache::lonnet::get_dom('configuration',['usercreation'],$domain);
@@ -191,7 +189,7 @@
     if ($env{'form.phase'} eq 'username_activation') {
         (my $result,$output,$nostart) = 
             &username_activation($r,$env{'form.uname'},$domain,$domdesc,
-                                 $lonhost,$courseid);
+                                 $courseid);
         if ($result eq 'ok') {
             if ($nostart) {
                 return OK;
@@ -621,8 +619,8 @@
         ($data{'username'}  =~ /^[^\@]+\@[^\@]+\.[^\@\.]+$/)) {
         if ($now - $data{'time'} < 7200) {
             if ($env{'form.phase'} eq 'createaccount') {
-                my ($result,$output) = &create_account($r,$domain,$lonhost,
-                                                       $data{'username'},$domdesc);
+                my ($result,$output,$uhome) = 
+                    &create_account($r,$domain,$data{'username'},$domdesc);
                 if ($result eq 'ok') {
                     $msg = $output; 
                     my $shownow = &Apache::lonlocal::locallocaltime($now);
@@ -635,8 +633,8 @@
                     } else {
                         $msg .= &mt('An error occurred when sending e-mail to [_1] confirming creation of your LON-CAPA account.',$data{'username'});
                     }
-                    &start_session($r, $data{'username'}, $domain, $lonhost,
-                        $data{'courseid'}, $token);
+                    &start_session($r,$data{'username'},$domain,$uhome,
+                                   $data{'courseid'},$token);
                     $nostart = 1;
                     $noend = 1;
                 } else {
@@ -663,10 +661,10 @@
 }
 
 sub start_session {
-    my ($r, $username, $domain, $lonhost, $courseid, $token) = @_;
+    my ($r,$username,$domain,$uhome,$courseid,$token) = @_;
 
     if ($r->dir_config('lonBalancer') eq 'yes') {
-        Apache::lonauth::success($r, $username, $domain, $lonhost,
+        Apache::lonauth::success($r, $username, $domain, $uhome,
             'noredirect', undef, {});
 
         Apache::lonnet::tmpdel($token) if $token;
@@ -675,7 +673,7 @@
     } else {
         $courseid = Apache::lonnet::is_course($courseid); 
 
-        Apache::lonauth::success($r, $username, $domain, $lonhost,
+        Apache::lonauth::success($r, $username, $domain, $uhome,
             ($courseid ? "/adm/selfenroll?courseid=$courseid" : '/adm/roles'),
             undef, {}); 
     }
@@ -809,7 +807,7 @@
 }
 
 sub create_account {
-    my ($r,$domain,$lonhost,$username,$domdesc) = @_;
+    my ($r,$domain,$username,$domdesc) = @_;
 # Get the token info
     my ($retrieved,$output,$upass) = &process_credentials($env{'form.logtoken'},
                                                           $env{'form.serverid'}); 
@@ -849,7 +847,7 @@
     my $uhome = &Apache::lonnet::homeserver($username,$domain);
     $output .= '<br />'.&mt('Home server: [_1]',$uhome).' '.
               &Apache::lonnet::hostname($uhome).'<br /><br />';
-    return ('ok',$output);
+    return ('ok',$output,$uhome);
 }
 
 sub username_validation {
@@ -875,7 +873,7 @@
     if ($uhome ne 'no_host') {
         my $result = &Apache::lonnet::authenticate($username,$upass,$domain);
         if ($result ne 'no_host') { 
-            &start_session($r, $username, $domain, $lonhost, $courseid);
+            &start_session($r,$username,$domain,$uhome,$courseid);
             $output = '<br /><br />'.&mt('A LON-CAPA account already exists for username [_1] at this institution ([_2]).','<tt>'.$username.'</tt>',$domdesc).'<br />'.&mt('The password entered was also correct so you have been logged in.');
             return ('existingaccount',$output);
         } else {
@@ -1029,7 +1027,7 @@
 }
 
 sub username_activation {
-    my ($r,$username,$domain,$domdesc,$lonhost,$courseid) = @_;
+    my ($r,$username,$domain,$domdesc,$courseid) = @_;
     my $output;
     my $error     = '<span class="LC_error">'.&mt('Error:').' ';
     my $end       = '</span><br /><br />';
@@ -1099,7 +1097,8 @@
         if ($result eq 'ok') {
             my $delete = &Apache::lonnet::tmpdel($env{'form.authtoken'});
             $output = &mt('A LON-CAPA account has been created for username: [_1] in domain: [_2].',$username,$domain);
-            &start_session($r, $username, $domain, $lonhost, $courseid);
+            my $uhome=&Apache::lonnet::homeserver($username,$domain,'true');
+            &start_session($r,$username,$domain,$uhome,$courseid);
             my $nostart = 1;
             return ('ok',$output,$nostart);
         } else {




More information about the LON-CAPA-cvs mailing list