--- loncom/interface/resetpw.pm 2016/09/12 16:02:16 1.38 +++ loncom/interface/resetpw.pm 2016/10/30 01:45:31 1.39 @@ -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.38 2016/09/12 16:02:16 raeburn Exp $ +# $Id: resetpw.pm,v 1.39 2016/10/30 01:45:31 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -196,7 +196,10 @@ END '

'.&mt('Reset forgotten LON-CAPA password').'

'; my $output; if ($token) { - $output = &reset_passwd($r,$token,$contact_name,$contact_email); + $r->print($header); + &reset_passwd($r,$token,$contact_name,$contact_email); + $r->print(&Apache::loncommon::end_page()); + return OK; } elsif ($udom) { if (!$domdesc) { $output = &invalid_state('baddomain',$domdesc, @@ -423,13 +426,13 @@ sub homeserver_redirect { sub reset_passwd { my ($r,$token,$contact_name,$contact_email) = @_; - my $msg; my %data = &Apache::lonnet::tmpget($token); my $now = time; if (keys(%data) == 0) { - $msg = &mt('Sorry, the URL you provided to complete the reset of your password was invalid. Either the token included in the URL has been deleted or the URL you provided was invalid. Please submit a [_1]new request[_2] for a password reset, and follow the link to the new URL included in the e-mail that will be sent to you, to allow you to enter a new password.' - ,'',''); - return $msg; + $r->print(&mt('Sorry, the URL you provided to complete the reset of your password was invalid. Either the token included in the URL has been deleted or the URL you provided was invalid. Please submit a [_1]new request[_2] for a password reset, and follow the link to the new URL included in the e-mail that will be sent to you, to allow you to enter a new password.' + ,'','') + ); + return; } if (($data{'time'} =~ /^\d+$/) && ($data{'username'} ne '') && @@ -440,13 +443,13 @@ sub reset_passwd { my ($blocked,$blocktext) = &Apache::loncommon::blocking_status('passwd',$data{'username'},$data{'domain'}); if ($blocked) { - $msg = '

'.$blocktext.'

'; - return $msg; + $r->print('

'.$blocktext.'

'); + return; } elsif ($now - $data{'time'} < 7200) { if ($env{'form.action'} eq 'verify_and_change_pass') { 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); - return $msg; + $r->print(&generic_failure_msg($contact_name,$contact_email)); + return; } my $change_failed = &Apache::lonpreferences::verify_and_change_password($r,'reset_by_email',$token); @@ -472,14 +475,15 @@ sub reset_passwd { .' confirming setting of your new password.' ,''.$data{'email'}.''),1); } - $msg .= + $r->print( &Apache::loncommon::confirmwrapper($confirm_msg) .&Apache::lonhtmlcommon::actionbox([ - ''.&mt('Go to the login page').'']); + ''.&mt('Go to the login page').'']) + ); } elsif ($change_failed eq 'invalid_client') { my $homeserver = &Apache::lonnet::homeserver($data{'username'},$data{'domain'}); if ($homeserver eq 'no_host') { - $msg .= &generic_failure_msg($contact_name,$contact_email); + $r->print(&generic_failure_msg($contact_name,$contact_email)); } else { my $protocol = $Apache::lonnet::protocol{$homeserver}; $protocol = 'http' if ($protocol ne 'https'); @@ -490,16 +494,17 @@ sub reset_passwd { $opentag = ''; $closetag = ''; } - $msg .= + $r->print( '

' .&mt('A problem occurred when attempting to reset' .' the password for your account.' .' Please try again from your [_1]home server[_2].' ,$opentag,$closetag) - .'

'; + .'

' + ); } } else { - $msg .= &generic_failure_msg($contact_name,$contact_email); + $r->print(&generic_failure_msg($contact_name,$contact_email)); } } 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).'

'); @@ -507,20 +512,22 @@ sub reset_passwd { &Apache::lonpreferences::passwordchanger($r,'','reset_by_email',$token); } } else { - $msg = + $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.' ,'','') - .'

'; + .'

' + ); } } else { - $msg .= + $r->print( '

' .&mt('Sorry, the URL generated when you requested reset of your password contained incomplete information. Please submit a [_1]new request[_2] for a password reset, and use the new URL that will be sent to your e-mail account to complete the process.' ,'','') - .'

'; + .'

' + ); } - return $msg; + return; } sub generic_failure_msg {