Diff for /loncom/interface/resetpw.pm between versions 1.22.2.2 and 1.24

version 1.22.2.2, 2010/09/19 15:04:40 version 1.24, 2010/03/22 20:11:22
Line 75  sub handler { Line 75  sub handler {
           
     my @emailtypes = ('permanentemail','critnotification','notification');      my @emailtypes = ('permanentemail','critnotification','notification');
     my $uname = &unescape($env{'form.uname'});      my $uname = &unescape($env{'form.uname'});
     my $useremail = $env{'form.useremail'};  
     my $udom = $env{'form.udom'};      my $udom = $env{'form.udom'};
     my $token = $env{'form.token'};      my $token = $env{'form.token'};
     my $case_change;  
     my $start_page =      my $start_page =
         &Apache::loncommon::start_page('Reset password','',          &Apache::loncommon::start_page('Reset password');
                                            {  
                                              'no_inline_link'   => 1,});  
     $r->print($start_page);      $r->print($start_page);
     $r->print('<h3>'.&mt('Reset forgotten LON-CAPA password').'</h3>');      $r->print('<h3>'.&mt('Reset forgotten LON-CAPA password').'</h3>');
     my $output;      my $output;
Line 90  sub handler { Line 86  sub handler {
         $output = &reset_passwd($r,$token,$contact_name,$contact_email);          $output = &reset_passwd($r,$token,$contact_name,$contact_email);
     } elsif ($uname && $udom) {      } elsif ($uname && $udom) {
         my $domdesc = &Apache::lonnet::domain($udom,'description');          my $domdesc = &Apache::lonnet::domain($udom,'description');
         my $homeserver = &Apache::lonnet::homeserver($uname,$udom);  
         if ($homeserver eq 'no_host') {  
             my $lc_uname =  lc($uname);  
             if ($lc_uname ne $uname) {  
                 $homeserver = &Apache::lonnet::homeserver($lc_uname,$udom);  
                 unless ($homeserver eq 'no_host') {  
                     $uname = $lc_uname;  
                     $useremail = lc($env{'form.useremail'});  
                     $case_change = 1;  
                 }  
             }  
         }  
         my $authtype = &Apache::lonnet::queryauthenticate($uname,$udom);          my $authtype = &Apache::lonnet::queryauthenticate($uname,$udom);
         if ($authtype =~ /^internal/) {          if ($authtype =~ /^internal/) {
               my $useremail = $env{'form.useremail'};
             if ($useremail !~ /^[^\@]+\@[^\@]+\.[^\@\.]+$/) {              if ($useremail !~ /^[^\@]+\@[^\@]+\.[^\@\.]+$/) {
                 $output = &invalid_state('baduseremail',$domdesc,                  $output = &invalid_state('baduseremail',$domdesc,
                                          $contact_name,$contact_email);                                           $contact_name,$contact_email);
Line 122  sub handler { Line 107  sub handler {
                     }                      }
                     foreach my $item (@items) {                      foreach my $item (@items) {
                         if ($item =~ /^[^\@]+\@[^\@]+\.[^\@\.]+$/) {                          if ($item =~ /^[^\@]+\@[^\@]+\.[^\@\.]+$/) {
                             if ($case_change) {                              unless(grep(/^\Q$item\E$/,@allemails)) { 
                                 my $lcitem = lc($item);                                  push(@allemails,$item);
                                 unless(grep(/^\Q$lcitem\E$/,@allemails)) {  
                                     push(@allemails,$lcitem);  
                                 }  
                             } else {  
                                 unless(grep(/^\Q$item\E$/,@allemails)) {   
                                     push(@allemails,$item);  
                                 }  
                             }                              }
                         }                          }
                     }                      }
Line 168  sub handler { Line 146  sub handler {
 sub get_uname {  sub get_uname {
     my ($defdom) = @_;      my ($defdom) = @_;
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
                                          unam => 'LON-CAPA username',                                           unam => 'username',
                                          udom => 'LON-CAPA domain',                                           udom => 'domain',
                                          uemail => 'E-mail address in LON-CAPA',                                           uemail => 'E-mail address in LON-CAPA',
                                          proc => 'Proceed');                                           proc => 'Proceed');
   
     my $msg = '<br />'.&mt('To be able to reset a forgotten password:')      my $msg = &mt('If you use the same account for other campus services besides LON-CAPA, (e.g., e-mail, course registration, etc.), a separate centrally managed mechanism likely exists to reset a password. However, if your account is used for just LON-CAPA access you will probably be able to reset a password from this page.');
       $msg .= '<br /><br />'.&mt('Three conditions must be met:')
            .'<ul><li>'.&mt('An e-mail address must have previously been associated with your LON-CAPA username.').'</li>'             .'<ul><li>'.&mt('An e-mail address must have previously been associated with your LON-CAPA username.').'</li>'
            .'<li>'.&mt('You must be able to access e-mail sent to the e-mail address associated with your WebCenter account.').'</li></ul><br />'             .'<li>'.&mt('You must be able to access e-mail sent to that address.').'</li>'
            .&mt('In most cases the GCI WebCenter username is the same as your e-mail address, in which case you will enter the same information twice. ').'<br />';             .'<li>'.&mt('Your LON-CAPA account must be of a type for which LON-CAPA can reset a password.')
     $msg .= '             .'</ul>';
       $msg .= qq|
 <form name="forgotpw" method="post">  <form name="forgotpw" method="post">
 <table>  <table>
  <tr>  <tr><td>
   <td align="left">'.$lt{'unam'}.':</td>  <tr><td align="left">LON-CAPA $lt{'unam'}:                      </td>
   <td><input type="text" name="uname" size="30" />      <td><input type="text" name="uname" size="15" /></td></tr>
       <input type="hidden" name="udom" value="'.$defdom.'" /></td>  <tr><td align="left">LON-CAPA $lt{'udom'}:                      </td>
  </tr>      <td>|;
  <tr>      $msg .= &Apache::loncommon::select_dom_form($defdom,'udom');
   <td align="left">'.$lt{'uemail'}.':</td>      $msg .= qq|</td></tr>
   <td><input type="text" name="useremail" size="30" /></td>  <tr><td align="left">$lt{'uemail'}:                             </td>
  </tr>      <td><input type="text" name="useremail" size="30" /></td></tr>
  <tr><td colspan="2" align="left"><br />  <tr><td colspan="2" align="left"><br />
     <input type="submit" value="'.$lt{'proc'}.'" /></td>      <input type="submit" value="$lt{'proc'}" /></td></tr>
  </tr>  
 </table>  </table>
 </form>'."\n";  </form>
   |;
     return $msg;      return $msg;
 }  }
   
Line 220  sub send_token { Line 200  sub send_token {
         my $result = &send_mail($domdesc,$email,$mailmsg,$contact_name,          my $result = &send_mail($domdesc,$email,$mailmsg,$contact_name,
                                 $contact_email);                                  $contact_email);
         if ($result eq 'ok') {          if ($result eq 'ok') {
             $msg .= &mt('An e-mail sent to the e-mail address associated with your LON-CAPA account includes the web address for the link you should use to complete the reset process.').'<br /><br />'.&mt('The link included in the message will be valid for the next [_1]two[_2] hours.','<b>','</b>');              $msg .= &mt("An e-mail sent to the e-mail address associated with your LON-CAPA account includes the web address for the link you should use to complete the reset process.<br /><br />The link included in the message will be valid for the next <b>two</b> hours.");
         } else {          } else {
             $msg .= &mt('An error occurred when sending a message to the e-mail address associated with your LON-CAPA account. Please contact the [_1] ([_2]) for assistance.',$contact_name,$contact_email);              $msg .= &mt("An error occurred when sending a message to the e-mail address associated with your LON-CAPA account. Please contact the [_1] ([_2]) for assistance.",$contact_name,$contact_email);
         }          }
     } else {      } else {
         $msg .= &mt('An error occurred creating a token required for the password reset process. Please contact the [_1] ([_2]) for assistance.',$contact_name,$contact_email);          $msg .= &mt("An error occurred creating a token required for the password reset process. Please contact the [_1] ([_2]) for assistance.",$contact_name,$contact_email);
     }      }
     return $msg;      return $msg;
 }  }
Line 294  sub reset_passwd { Line 274  sub reset_passwd {
         my $reqtime = &Apache::lonlocal::locallocaltime($data{'time'});          my $reqtime = &Apache::lonlocal::locallocaltime($data{'time'});
         if ($now - $data{'time'} < 7200) {          if ($now - $data{'time'} < 7200) {
             if ($env{'form.action'} eq 'verify_and_change_pass') {              if ($env{'form.action'} eq 'verify_and_change_pass') {
                 my $homeserver = &Apache::lonnet::homeserver($env{'form.uname'},$env{'form.udom'});  
                 if ($homeserver eq 'no_host') {  
                     my $lc_uname =  lc($env{'form.uname'});  
                     if ($lc_uname ne $env{'form.uname'}) {  
                         $homeserver = &Apache::lonnet::homeserver($lc_uname,$env{'form.udom'});  
                         unless ($homeserver eq 'no_host') {  
                             if ($env{'form.uname'} eq $env{'form.email'}) {  
                                 $env{'form.email'} = $lc_uname;  
                             }  
                             $env{'form.uname'} = $lc_uname;  
                         }  
                     }  
                 }  
                 unless (($env{'form.uname'} eq $data{'username'}) && ($env{'form.udom'} eq $data{'domain'}) && ($env{'form.email'} eq $data{'email'})) {                  unless (($env{'form.uname'} eq $data{'username'}) && ($env{'form.udom'} eq $data{'domain'}) && ($env{'form.email'} eq $data{'email'})) {
                     $msg = &generic_failure_msg($contact_name,$contact_email);                      $msg = &generic_failure_msg($contact_name,$contact_email);
                     return $msg;                      return $msg;
Line 348  sub reset_passwd { Line 315  sub reset_passwd {
                     $msg .= &generic_failure_msg($contact_name,$contact_email);                      $msg .= &generic_failure_msg($contact_name,$contact_email);
                 }                  }
             } else {              } else {
                 $r->print(&mt('The token included in an e-mail sent to you [_1] has been verified, so you may now proceed to reset the password for your LON-CAPA account.',$reqtime).'<br />'.                  $r->print(&mt('The token included in an e-mail sent to you [_1] has been verified, so you may now proceed to reset the password for your LON-CAPA account.',$reqtime).'<br /><br />');
                           '<p>'.&mt('Please enter the username and domain of the LON-CAPA account, and the associated e-mail address, for which you are setting a password.').'<br />'.                  $r->print(&mt('Please enter the username and domain of the LON-CAPA account, and the associated e-mail address, for which you are setting a password. The new password must contain at least 7 characters.').' '.&mt('Your new password will be sent to the LON-CAPA server in an encrypted form.').'<br />');
                           &mt('In most cases the GCI WebCenter username is the same as your e-mail address, in which case you will enter the same information twice.').'</p>'.  
                           '<p>'.&mt('The new password must contain at least 7 characters.').' '.  
                           &mt('Your new password will be sent to the LON-CAPA server in an encrypted form.').'<br /></p>');  
                 &Apache::lonpreferences::passwordchanger($r,'','reset_by_email',$token);                  &Apache::lonpreferences::passwordchanger($r,'','reset_by_email',$token);
             }              }
         } else {          } else {

Removed from v.1.22.2.2  
changed lines
  Added in v.1.24


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