Diff for /loncom/auth/migrateuser.pm between versions 1.19 and 1.23

version 1.19, 2013/09/29 13:07:25 version 1.23, 2014/10/06 00:48:44
Line 72  sub ip_changed { Line 72  sub ip_changed {
     if (ref($dataref) eq 'HASH') {      if (ref($dataref) eq 'HASH') {
         my $title = 'LON-CAPA Session redirected';          my $title = 'LON-CAPA Session redirected';
         my $message = &mt('Your internet address has changed since you logged in.');            my $message = &mt('Your internet address has changed since you logged in.');  
         my $camefrom = &Apache::lonnet::hostname($dataref->{'server'});  
         my $frombalancer = $dataref->{'balancer'};  
         my $rule_in_effect;          my $rule_in_effect;
         if ($frombalancer) {          if ($dataref->{'balancer'}) {
             my $balancerdom = &Apache::lonnet::host_domain($dataref->{'server'});              my $baldom = &Apache::lonnet::host_domain($camefrom);
             my ($result,$cached)=&Apache::lonnet::is_cached_new('loadbalancing',$balancerdom);              my $balprimaryid = &Apache::lonnet::domain($baldom,'primary');
               my $balintdom = &Apache::lonnet::internet_dom($balprimaryid);
               my $uprimaryid = &Apache::lonnet::domain($udom,'primary'); 
               my $uintdom = &Apache::lonnet::internet_dom($uprimaryid);
               my $dom_in_use;
               if (($uintdom ne '') && ($uintdom eq $balintdom)) {
                   $dom_in_use = $udom;
               } else {
                   $dom_in_use = $baldom;
               }
               my ($result,$cached)=&Apache::lonnet::is_cached_new('loadbalancing',$dom_in_use);
             unless (defined($cached)) {              unless (defined($cached)) {
                 my $cachetime = 60*60*24;                   my $cachetime = 60*60*24; 
                 my %domconfig =                  my %domconfig =
                     &Apache::lonnet::get_dom('configuration',['loadbalancing'],$balancerdom);                      &Apache::lonnet::get_dom('configuration',['loadbalancing'],$dom_in_use);
                 if (ref($domconfig{'loadbalancing'}) eq 'HASH') {                  if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
                     $result = &Apache::lonnet::do_cache_new('loadbalancing',$balancerdom,                      $result = &Apache::lonnet::do_cache_new('loadbalancing',$dom_in_use,
                                                             $domconfig{'loadbalancing'},$cachetime);                                                              $domconfig{'loadbalancing'},$cachetime);
                 }                  }
             }              }
Line 106  sub ip_changed { Line 114  sub ip_changed {
         my $url;          my $url;
         my $lonhost= $r->dir_config('lonHostID');          my $lonhost= $r->dir_config('lonHostID');
         my $switchto = $lonhost;          my $switchto = $lonhost;
         if ($rule_in_effect eq 'balancer') {          if ($rule_in_effect ne 'offloadedto') {
             my $hosthere;              my $hosthere;
             if ($dataref->{'role'}) {              my @ids=&Apache::lonnet::current_machine_ids();
                 my ($adom,$aname);              unless ($rule_in_effect eq 'balancer') {
                 if ($dataref->{'role'} =~ m{^au\./($match_domain)/$}) {                  if (grep(/^\Q$rule_in_effect\E$/,@ids)) {
                     $adom = $1;                      $hosthere = 1;
                     $aname = $dataref->{'username'};                  }
                 } elsif ($dataref->{'role'} =~ m{^(?:ca|aa)\./($match_domain)/($match_username)$}) {              }
                     $adom = $1;              unless ($hosthere) {
                     $aname = $2;                  if ($dataref->{'role'}) {
                 }                      my ($adom,$aname);
                 if ($adom ne '' && $aname ne '') {                      if ($dataref->{'role'} =~ m{^au\./($match_domain)/$}) {
                     my $ahome = &Apache::lonnet::homeserver($aname,$adom);                          $adom = $1;
                     unless ($ahome eq 'no_host') {                          $aname = $dataref->{'username'};
                         my @ids=&Apache::lonnet::current_machine_ids();                      } elsif ($dataref->{'role'} =~ m{^(?:ca|aa)\./($match_domain)/($match_username)$}) {
                         if ($ahome && grep(/^\Q$ahome\E$/,@ids)) {                          $adom = $1;
                             $hosthere = 1;                          $aname = $2;
                       }
                       if ($adom ne '' && $aname ne '') {
                           my $ahome = &Apache::lonnet::homeserver($aname,$adom);
                           unless ($ahome eq 'no_host') {
                               if ($ahome && grep(/^\Q$ahome\E$/,@ids)) {
                                   $hosthere = 1;
                               }
                         }                          }
                     }                      }
                 }                  }
             }              }
             unless ($hosthere) {               unless ($hosthere) {
                 my $hostname = &Apache::lonnet::hostname($dataref->{'server'});                  my $hostname;
                   if ($rule_in_effect eq 'balancer') {
                       $hostname = &Apache::lonnet::hostname($dataref->{'server'});
                       if ($hostname) {
                           $switchto = $dataref->{'server'};
                       }
                   } else {
                       $hostname = &Apache::lonnet::hostname($rule_in_effect);
                       if ($hostname) {
                           $switchto = $rule_in_effect;
                       }
                   }
                 if ($hostname) {                  if ($hostname) {
                     $switchto = $dataref->{'server'};  
                     my $protocol = $Apache::lonnet::protocol{$switchto};                      my $protocol = $Apache::lonnet::protocol{$switchto};
                     $protocol = 'http' if ($protocol ne 'https');                      $protocol = 'http' if ($protocol ne 'https');
                     $url = $protocol.'://'.$hostname;                      $url = $protocol.'://'.$hostname;
                     $message .= '<br />'.                      if ($rule_in_effect eq 'balancer') {
                                 &mt('As a result, your LON-CAPA session is being redirected to the server where you originally logged in.');                          $message .= '<br />'.
                                       &mt('As a result, your LON-CAPA session is being redirected to the server where you originally logged in.');
                       } else {
                           $message .= '<br />'.
                                       &mt('As a result, your LON-CAPA session is being redirected.');
                       }
                 }                  }
             }              }
         }          }
         if ($dataref->{'sso.login'}) {          if ($dataref->{'sso.login'}) {
             $url .= '/adm/roles?';              $url .= '/adm/roles';
         } else {          } else {
             $url .= '/adm/login?';              $url .= '/adm/login';
             $message .= '<br />'.&mt('You will need to provide your password one more time');              $message .= '<br />'.&mt('You will need to provide your password one more time.');
         }          }
         my %info= (          my %info= (
                     'domain'          => $dataref->{'domain'},                      'domain'          => $dataref->{'domain'},
Line 159  sub ip_changed { Line 189  sub ip_changed {
         }          }
         my $iptoken = &Apache::lonnet::tmpput(\%info,$switchto);          my $iptoken = &Apache::lonnet::tmpput(\%info,$switchto);
         unless ($iptoken eq 'conlost') {          unless ($iptoken eq 'conlost') {
             $url .= 'iptoken='.$iptoken;              $url .= '?iptoken='.$iptoken;
         }          }
         $r->print(&Apache::loncommon::start_page($title,undef,          $r->print(&Apache::loncommon::start_page($title,undef,
                                                  {'redirect' =>                                                   {'redirect' =>
Line 206  sub handler { Line 236  sub handler {
     if ($data{'symb'} ne '') {      if ($data{'symb'} ne '') {
         $form{'symb'} = $data{'symb'};          $form{'symb'} = $data{'symb'};
     }      }
       if ($data{'iptoken'} ne '') {
           $form{'iptoken'} = $data{'iptoken'};
       }
   
     if (!$data{'role'}) {      if (!$data{'role'}) {
  my $handle = &Apache::lonnet::check_for_valid_session($r);   my $handle = &Apache::lonnet::check_for_valid_session($r);

Removed from v.1.19  
changed lines
  Added in v.1.23


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>