Bug 10796: Use $category->effective_change_password in the OPAC

This patch makes the OPAC pages that rely on OpacPasswordChange use the
current patron's category to make the decision to allow password change
or not.

It does so by making sure all the places in which OpacPasswordChange was
used, use $logged_in_user->category->effective_change_password instead.

Special attention is required on the case of opac-registration-verify.pl
in which the use of an unblessed Koha::Patron object is changed in
favour of the blessed object, so we can actually use the new method to
make a decision on the text to display.

To test:
- Go through the OPAC pages, check that the password change strings and
links are displayed only whne appropriate.
- Sign off :-D

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Tomas Cohen Arazi 2019-02-20 13:58:35 -03:00 committed by Nick Clemens
parent d96fc92856
commit e155e6d5bb
6 changed files with 12 additions and 12 deletions

View File

@ -40,7 +40,7 @@
<a href="/cgi-bin/koha/opac-tags.pl?mine=1">your tags</a></li>
[% END %]
[% IF ( OpacPasswordChange ) %]
[% IF logged_in_user.category.effective_change_password %]
[% IF ( passwdview ) %]
<li class="active">
[% ELSE %]

View File

@ -51,7 +51,7 @@
</div>
[% END # /IF Error_messages %]
[% IF ( OpacPasswordChange ) %]
[% IF logged_in_user.category.effective_change_password %]
[% IF ( Ask_data ) %]
@ -71,7 +71,7 @@
[% END # /IF Ask_data %]
[% ELSE %]
<div class="alert">You can't change your password.</div>
[% END # /IF OpacPasswordChange %]
[% END # /IF logged_in_user.category.effective_change_password %]
[% IF ( password_updated ) %]
<div class="alert alert-success">

View File

@ -53,7 +53,13 @@
</p>
[% END %]
<p id="patron-instructions">For your convenience, the login box on this page has been pre-filled with this data. Please log in[% IF OpacPasswordChange %] and change your password[% END %].</p>
<p id="patron-instructions">
[% IF borrower.category.effective_change_password %]
<span>For your convenience, the login box on this page has been pre-filled with this data. Please log in and change your password.</span>
[% ELSE %]
<span>For your convenience, the login box on this page has been pre-filled with this data. Please log in.</span>
[% END %]
</p>
[% END %]
<div id="PatronSelfRegistrationAdditionalInstructions">[% PatronSelfRegistrationAdditionalInstructions | $raw %]</div>

View File

@ -205,9 +205,6 @@ if ( $action eq 'create' ) {
}
);
$template->param( OpacPasswordChange =>
C4::Context->preference('OpacPasswordChange') );
$borrower{categorycode} ||= C4::Context->preference('PatronSelfRegistrationDefaultCategory');
$borrower{password} ||= Koha::AuthUtils::generate_password;
my $consent_dt = delete $borrower{gdpr_proc_consent};

View File

@ -44,7 +44,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
);
my $patron = Koha::Patrons->find( $borrowernumber );
if ( C4::Context->preference("OpacPasswordChange") ) {
if ( $patron->category->effective_change_password ) {
if ( $query->param('Oldkey')
&& $query->param('Newkey')
&& $query->param('Confirm') )

View File

@ -58,9 +58,6 @@ if (
}
);
$template->param(
OpacPasswordChange => C4::Context->preference('OpacPasswordChange') );
my $patron_attrs = $m->unblessed;
$patron_attrs->{password} ||= Koha::AuthUtils::generate_password;
my $consent_dt = delete $patron_attrs->{gdpr_proc_consent};
@ -76,7 +73,7 @@ if (
C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $patron->borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if C4::Context->preference('EnhancedMessagingPreferences');
$template->param( password_cleartext => $patron->plain_text_password );
$template->param( borrower => $patron->unblessed );
$template->param( borrower => $patron );
$template->param(
PatronSelfRegistrationAdditionalInstructions =>
C4::Context->preference(