--- loncom/interface/lonpreferences.pm 2018/09/03 14:03:03 1.196.4.24 +++ loncom/interface/lonpreferences.pm 2019/08/22 00:00:03 1.196.4.25 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.196.4.24 2018/09/03 14:03:03 raeburn Exp $ +# $Id: lonpreferences.pm,v 1.196.4.25 2019/08/22 00:00:03 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -27,8 +27,6 @@ # # This package uses the "londes.js" javascript code. # -# TODOs that have to be completed: -# interface with lonnet to change the password package Apache::lonpreferences; @@ -477,7 +475,6 @@ sub verify_and_change_rolespref { } - ################################################################ # Anonymous Discussion Name Change Subroutines # ################################################################ @@ -1229,7 +1226,7 @@ sub verify_and_change_colors { # password handler subroutines # ###################################################### sub passwordchanger { - my ($r,$errormessage,$caller,$mailtoken) = @_; + my ($r,$errormessage,$caller,$mailtoken,$timelimit,$extrafields) = @_; # This function is a bit of a mess.... # Passwords are encrypted using londes.js (DES encryption) $errormessage = ($errormessage || ''); @@ -1254,42 +1251,42 @@ sub passwordchanger { $caller = 'preferences'; } } elsif ($caller eq 'reset_by_email') { - my %data = &Apache::lonnet::tmpget($mailtoken); - if (keys(%data) == 0) { - $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 (defined($data{time})) { - if (time - $data{'time'} < 7200) { - $user = $data{'username'}; - $domain = $data{'domain'}; - $currentpass = $data{'temppasswd'}; - } else { - $r->print( - '

' - .&mt('Sorry, the token generated when you requested' - .' a password reset has expired.') - .'

' - ); - return; - } + my %data = &Apache::lonnet::tmpget($mailtoken); + if (keys(%data) == 0) { + $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 (defined($data{time})) { + if (time - $data{'time'} < $timelimit) { + $user = $data{'username'}; + $domain = $data{'domain'}; + $currentpass = $data{'temppasswd'}; } else { $r->print( - '

' - .&mt('Sorry, the URL generated when you requested reset of' - .' your password contained incomplete information.') + '

' + .&mt('Sorry, the token generated when you requested' + .' a password reset has expired.') .'

' ); return; } - if (&Apache::lonnet::domain($domain) eq '') { - $domain = $r->dir_config('lonDefDomain'); - } + } else { + $r->print( + '

' + .&mt('Sorry, the URL generated when you requested reset of' + .' your password contained incomplete information.') + .'

' + ); + return; + } + if (&Apache::lonnet::domain($domain) eq '') { + $domain = $r->dir_config('lonDefDomain'); + } } else { $r->print( '

' @@ -1328,7 +1325,7 @@ sub passwordchanger { my $jsh=Apache::File->new($include."/londes.js"); $r->print(<$jsh>); } - $r->print(&jscript_send($caller)); + $r->print(&jscript_send($caller,$extrafields)); $r->print(< ENDFORM - $r->print(&server_form($logtoken,$caller,$mailtoken)); - $r->print(&client_form($caller,\%hexkey,$currentpass,$domain)); + $r->print(&server_form($logtoken,$caller,$mailtoken,$extrafields)); + $r->print(&client_form($caller,\%hexkey,$currentpass,$domain,$extrafields)); # return; } sub jscript_send { - my ($caller) = @_; + my ($caller,$extrafields) = @_; my $output = qq|