X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=opac%2Fopac-passwd.pl;h=19425f79377083bf1bf1c0322d1b3101505c9766;hb=26b2bd1fe02012115a5bf9736e8d446f4bc52a9e;hp=860f62a11062e649f191c15dfe55a8067f3ab6af;hpb=7ceb48fc1576f50e5182a700b86a31c8c6562c32;p=koha_fer diff --git a/opac/opac-passwd.pl b/opac/opac-passwd.pl index 860f62a110..19425f7937 100755 --- a/opac/opac-passwd.pl +++ b/opac/opac-passwd.pl @@ -14,12 +14,13 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; -require Exporter; +use warnings; + use CGI; use C4::Auth; # checkauth, getborrowernumber. @@ -44,61 +45,63 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( ); # get borrower information .... -my ( $borr, $flags ) = GetMemberDetails( $borrowernumber ); -my $sth = $dbh->prepare("UPDATE borrowers SET password = ? WHERE borrowernumber=?"); +my ( $borr ) = GetMemberDetails( $borrowernumber ); my $minpasslen = C4::Context->preference("minPasswordLength"); -if ( $query->param('Oldkey') - && $query->param('Newkey') - && $query->param('Confirm') ) -{ - if ( goodkey( $dbh, $borrowernumber, $query->param('Oldkey') ) ) { - if ( $query->param('Newkey') eq $query->param('Confirm') - && length( $query->param('Confirm') ) >= $minpasslen ) - { # Record password - my $clave = md5_base64( $query->param('Newkey') ); - $sth->execute( $clave, $borrowernumber ); - $template->param( 'password_updated' => '1' ); - $template->param( 'borrowernumber' => $borrowernumber ); +if ( C4::Context->preference("OpacPasswordChange") ) { + my $sth = $dbh->prepare("UPDATE borrowers SET password = ? WHERE borrowernumber=?"); + if ( $query->param('Oldkey') + && $query->param('Newkey') + && $query->param('Confirm') ) + { + if ( goodkey( $dbh, $borrowernumber, $query->param('Oldkey') ) ) { + if ( $query->param('Newkey') eq $query->param('Confirm') + && length( $query->param('Confirm') ) >= $minpasslen ) + { # Record password + my $clave = md5_base64( $query->param('Newkey') ); + $sth->execute( $clave, $borrowernumber ); + $template->param( 'password_updated' => '1' ); + $template->param( 'borrowernumber' => $borrowernumber ); + } + elsif ( $query->param('Newkey') ne $query->param('Confirm') ) { + $template->param( 'Ask_data' => '1' ); + $template->param( 'Error_messages' => '1' ); + $template->param( 'PassMismatch' => '1' ); + } + elsif ( length( $query->param('Confirm') ) < $minpasslen ) { + $template->param( 'Ask_data' => '1' ); + $template->param( 'Error_messages' => '1' ); + $template->param( 'ShortPass' => '1' ); + } + else { + $template->param( 'Error_messages' => '1' ); + } } - elsif ( $query->param('Newkey') ne $query->param('Confirm') ) { + else { $template->param( 'Ask_data' => '1' ); $template->param( 'Error_messages' => '1' ); - $template->param( 'PassMismatch' => '1' ); + $template->param( 'WrongPass' => '1' ); } - elsif ( length( $query->param('Confirm') ) < $minpasslen ) { - $template->param( 'Ask_data' => '1' ); + } + else { + + # Called Empty, Ask for data. + $template->param( 'Ask_data' => '1' ); + if (!$query->param('Oldkey') && ($query->param('Newkey') || $query->param('Confirm'))){ + # Old password is empty but one of the others isnt $template->param( 'Error_messages' => '1' ); - $template->param( 'ShortPass' => '1' ); + $template->param( 'WrongPass' => '1' ); } - else { + elsif ($query->param('Oldkey') && (!$query->param('Newkey') || !$query->param('Confirm'))){ + # Oldpassword is entered but one of the other fields is empty $template->param( 'Error_messages' => '1' ); + $template->param( 'PassMismatch' => '1' ); } } - else { - $template->param( 'Ask_data' => '1' ); - $template->param( 'Error_messages' => '1' ); - $template->param( 'WrongPass' => '1' ); - } -} -else { - - # Called Empty, Ask for data. - $template->param( 'Ask_data' => '1' ); - if (!$query->param('Oldkey') && ($query->param('Newkey') || $query->param('Confirm'))){ - # Old password is empty but one of the others isnt - $template->param( 'Error_messages' => '1' ); - $template->param( 'WrongPass' => '1' ); - } - elsif ($query->param('Oldkey') && (!$query->param('Newkey') || !$query->param('Confirm'))){ - # Oldpassword is entered but one of the other fields is empty - $template->param( 'Error_messages' => '1' ); - $template->param( 'PassMismatch' => '1' ); - } } - $template->param(firstname => $borr->{'firstname'}, surname => $borr->{'surname'}, minpasslen => $minpasslen, + passwdview => 1, ); output_html_with_http_headers $query, $cookie, $template->output;