--- loncom/interface/resetpw.pm 2019/08/30 00:09:39 1.46 +++ loncom/interface/resetpw.pm 2020/02/09 04:43:20 1.47 @@ -1,7 +1,7 @@ # The LearningOnline Network # Allow access to password changing via a token sent to user's e-mail. # -# $Id: resetpw.pm,v 1.46 2019/08/30 00:09:39 raeburn Exp $ +# $Id: resetpw.pm,v 1.47 2020/02/09 04:43:20 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -639,7 +639,9 @@ sub reset_passwd { $invalidinfo = "||$env{'form.uname'}|| ||$env{'form.udom'}|| "; } } else { - unless ((lc($env{'form.uname'}) eq lc($data{'username'})) && (lc($env{'form.udom'}) eq lc($data{'domain'}))) { + if ((lc($env{'form.uname'}) eq lc($data{'username'})) && (lc($env{'form.udom'}) eq lc($data{'domain'}))) { + $env{'form.uname'} = $data{'username'}; + } else { $invalidinfo = "||$env{'form.uname'}|| ||$env{'form.udom'}|| "; } } @@ -661,7 +663,53 @@ sub reset_passwd { } if ($invalidinfo) { &Apache::lonnet::logthis("Forgot Password -- token data: ||$data{'username'}|| ||$data{'domain'}|| ||$data{'email'}|| differs from form: $invalidinfo"); - $r->print(&generic_failure_msg($contact_name,$contact_email)); + my $retry; + $r->print( + '
' + .&mt('A problem occurred when attempting to reset' + .' the password for your account.').'
'); + if (($formfields{'username'}) && ($formfields{'email'})) { + if ($needscase) { + $r->print('' + .&mt('Please verify you entered the correct username and e-mail address, ' + .'including the correct lower and/or upper case letters') + .'
'); + } else { + $r->print('' + .&mt('Please verify you entered the correct username and e-mail address.') + .'
'); + } + $retry = 1; + } elsif ($formfields{'username'}) { + if ($needscase) { + $r->print('' + .&mt('Please verify you entered the correct username, ' + .'including the correct lower and/or upper case letters') + .'
'); + } else { + $r->print('' + .&mt('Please verify you entered the correct username.') + .'
'); + } + $retry = 1; + } elsif ($formfields{'email'}) { + if ($needscase) { + $r->print('' + .&mt('Please verify you entered the correct e-mail address, ' + .'including the correct lower and/or upper case letters') + .'
'); + } else { + $r->print('' + .&mt('Please verify you entered the correct e-mail address.') + .'
'); + } + $retry = 1; + } + if ($retry) { + &Apache::lonpreferences::passwordchanger($r,'','reset_by_email',$token,$timelimit,\%formfields); + } else { + $r->print(&generic_failure_msg($contact_name,$contact_email)); + } unless ($formfields{'username'}) { delete($env{'form.uname'}); delete($env{'form.udom'}); @@ -669,7 +717,7 @@ sub reset_passwd { return; } my $change_failed = - &Apache::lonpreferences::verify_and_change_password($r,'reset_by_email',$token); + &Apache::lonpreferences::verify_and_change_password($r,'reset_by_email',$token,$timelimit,\%formfields); if (!$change_failed) { my $delete = &Apache::lonnet::tmpdel($token); my $now = &Apache::lonlocal::locallocaltime(time); @@ -729,7 +777,8 @@ sub reset_passwd { .'' .&display_actions($contact_email,$domdesc,$token) ); - } else { + } elsif (($change_failed eq 'internalerror') || ($change_failed eq 'missingtemp') || + ($change_failed eq 'error')) { $r->print(&generic_failure_msg($contact_name,$contact_email)); } unless ($formfields{'username'}) { @@ -749,7 +798,20 @@ sub reset_passwd { if ($needscase) { $r->print(' '.&mt('User data entered must match LON-CAPA account information (including case).')); } - $r->print(' '); + $r->print(''
- .&mt('Sorry, the token generated when you requested a password reset has expired. Please submit a [_1]new request[_2], and follow the link to the web page included in the new e-mail that will be sent to you, to allow you to enter a new password.'
+ .&mt('Sorry, the token generated when you requested a password reset has expired.').'
'
+ .&mt('Please submit a [_1]new request[_2], and follow the link to the web page included in the new e-mail that will be sent to you, to allow you to enter a new password.'
,'','')
.'