my $BlockExpiredPatronOpacActions = $input->param('BlockExpiredPatronOpacActions');
my $checkPrevCheckout = $input->param('checkprevcheckout');
my $default_privacy = $input->param('default_privacy');
- my $can_reset_password = $input->param('can_reset_password');
+ my $reset_password = $input->param('reset_password');
my @branches = grep { $_ ne q{} } $input->multi_param('branches');
+ $reset_password = undef if $reset_password eq -1;
+
my $is_a_modif = $input->param("is_a_modif");
if ($enrolmentperioddate) {
$category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
$category->checkprevcheckout($checkPrevCheckout);
$category->default_privacy($default_privacy);
- $category->can_reset_password($can_reset_password);
+ $category->reset_password($reset_password);
eval {
$category->store;
$category->replace_branch_limitations( \@branches );
BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
checkprevcheckout => $checkPrevCheckout,
default_privacy => $default_privacy,
- can_reset_password => $can_reset_password,
+ reset_password => $reset_password,
});
eval {
$category->store;
</span>
</li>
<li>
- <label for="can_reset_password">Password reset in OPAC: </label>
- <select name="can_reset_password" id="can_reset_password">
- [% IF category.can_reset_password %]
- <option value="0">Allowed</option>
- <option value="1" selected="selected">Not allowed</option>
+ <label for="reset_password">Password reset in OPAC: </label>
+ <select name="reset_password" id="reset_password">
+ [% IF category.reset_password.defined %]
+ [% IF category.reset_password %]
+ [% IF Koha.Preference('OpacResetPassword') %]
+ <option value="-1">Follow system preference OpacResetPassword (enabled)</option>
+ [% ELSE %]
+ <option value="-1">Follow system preference OpacResetPassword (disabled)</option>
+ [% END %]
+ <option value="1" selected="selected">Allowed</option>
+ <option value="0">Not allowed</option>
[% ELSE %]
- <option value="0" selected="selected">Allowed</option>
- <option value="1">Not allowed</option>
+ [% IF Koha.Preference('OpacResetPassword') %]
+ <option value="-1">Follow system preference OpacResetPassword (enabled)</option>
+ [% ELSE %]
+ <option value="-1">Follow system preference OpacResetPassword (disabled)</option>
+ [% END %]
+ <option value="1">Allowed</option>
+ <option value="0" selected="selected">Not allowed</option>
[% END %]
+ [% ELSE %]
+ [% IF Koha.Preference('OpacResetPassword') %]
+ <option value="-1" selected="selected">Follow system preference OpacResetPassword (enabled)</option>
+ [% ELSE %]
+ <option value="-1" selected="selected">Follow system preference OpacResetPassword (disabled)</option>
+ [% END %]
+ <option value="1">Allowed</option>
+ <option value="0">Not allowed</option>
+ [% END %]
</select>
</li>
<li><label for="block_expired">Block expired patrons:</label>
[% USE raw %]
[% USE Koha %]
[% USE Branches %]
+[% USE Categories %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha ›
[% IF too_many_login_attempts %]
<div id="login_error"><strong>Error: </strong>This account has been locked!</div>
- [% IF Koha.Preference('OpacResetPassword') && Koha.Preference('OpacBaseURL') %]
+ [% IF Categories.can_any_reset_password && Koha.Preference('OpacBaseURL') %]
<a href="[% Koha.Preference('OpacBaseURL') | url %]/cgi-bin/koha/opac-password-recovery.pl">You must reset your password</a>.
[% END %]
[% ELSIF invalid_username_or_password %]
[% USE raw %]
[% USE Koha %]
[% USE Branches %]
+[% USE Categories %]
[% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %]
<div id="wrap">
<div id="header-region" class="noprint">
[% Koha.Preference( 'OpacLoginInstructions' ) | $raw %]
</div>
[% END %]
- [% IF Koha.Preference('OpacPasswordChange') && Koha.Preference('OpacResetPassword') %]
+ [% IF Koha.Preference('OpacPasswordChange') && Categories.can_any_reset_password %]
<div id="forgotpassword-modal" class="forgotpassword">
<a href="/cgi-bin/koha/opac-password-recovery.pl">Forgot your password?</a>
</div>
[% USE raw %]
[% USE Koha %]
+[% USE Categories %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog ›
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
<input type="submit" value="Log in" class="btn" />
<p/>
- [% IF Koha.Preference('OpacPasswordChange') && Koha.Preference('OpacResetPassword') %]
+ [% IF Koha.Preference('OpacPasswordChange') && Categories.can_any_reset_password %]
<div id="forgotpassword">
<a href="/cgi-bin/koha/opac-password-recovery.pl">Forgot your password?</a>
</div>
[% USE Koha %]
[% USE KohaDates %]
[% USE Branches %]
+[% USE Categories %]
[% USE Price %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
[% Koha.Preference( 'OpacLoginInstructions' ) | $raw %]
</div>
[% END %]
- [% IF Koha.Preference('OpacPasswordChange') && Koha.Preference('OpacResetPassword') %]
+ [% IF Koha.Preference('OpacPasswordChange') && Categories.can_any_reset_password %]
<div id="forgotpassword-main" class="forgotpassword">
<p><a href="/cgi-bin/koha/opac-password-recovery.pl">Forgot your password?</a></p>
</div>
[% USE Koha %]
+[% USE Categories %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog › Forgotten password recovery</title>
[% INCLUDE 'doc-head-close.inc' %]
<br/>Please try again later.
[% ELSIF (errNoBorrowerFound) %]
No account was found with the provided information.
+ [% ELSIF errResetForbidden %]
+ You are not allowed to reset your password. Contact library staff for assistance.
[% ELSIF (errMultipleAccountsForEmail) %]
Account identification with this email address only is ambiguous.
<br />Please use the field 'Login' as well.
</div>
[% END %]
<div id="password-recovery">
-[% IF (!Koha.Preference('OpacResetPassword')) %]
+[% IF (! Categories.can_any_reset_password ) %]
<div class="alert alert-info">You can't reset your password.</div>
[% ELSIF (password_recovery) %]
<form action="/cgi-bin/koha/opac-password-recovery.pl" method="post" autocomplete="off">
my $errAlreadyStartRecovery;
my $errTooManyEmailFound;
my $errBadEmail;
+my $errResetForbidden;
#new password form error
my $errLinkNotValid;
$errMultipleAccountsForEmail = 1;
}
elsif ( $borrower = $search_results->next() ) { # One matching borrower
- my @emails = grep { $_ } ( $borrower->email, $borrower->emailpro, $borrower->B_email );
- my $firstNonEmptyEmail;
- $firstNonEmptyEmail = $emails[0] if @emails;
+ if ( $borrower->category->effective_reset_password ) {
- # Is the given email one of the borrower's ?
- if ( $email && !( grep /^$email$/i, @emails ) ) {
- $hasError = 1;
- $errNoBorrowerFound = 1;
- }
+ my @emails = grep { $_ } ( $borrower->email, $borrower->emailpro, $borrower->B_email );
- # If there is no given email, and there is no email on record
- elsif ( !$email && !$firstNonEmptyEmail ) {
- $hasError = 1;
- $errNoBorrowerEmail = 1;
- }
+ my $firstNonEmptyEmail;
+ $firstNonEmptyEmail = $emails[0] if @emails;
+
+ # Is the given email one of the borrower's ?
+ if ( $email && !( grep /^$email$/i, @emails ) ) {
+ $hasError = 1;
+ $errNoBorrowerFound = 1;
+ }
+
+ # If there is no given email, and there is no email on record
+ elsif ( !$email && !$firstNonEmptyEmail ) {
+ $hasError = 1;
+ $errNoBorrowerEmail = 1;
+ }
-# Check if a password reset already issued for this borrower AND we are not asking for a new email
- elsif ( not $query->param('resendEmail') ) {
- if ( ValidateBorrowernumber( $borrower->borrowernumber ) ) {
- $hasError = 1;
- $errAlreadyStartRecovery = 1;
+ # Check if a password reset already issued for this
+ # borrower AND we are not asking for a new email
+ elsif ( not $query->param('resendEmail') ) {
+ if ( ValidateBorrowernumber( $borrower->borrowernumber ) ) {
+ $hasError = 1;
+ $errAlreadyStartRecovery = 1;
+ }
+ else {
+ DeleteExpiredPasswordRecovery( $borrower->borrowernumber );
+ }
}
- else {
- DeleteExpiredPasswordRecovery( $borrower->borrowernumber );
+ # Set the $email, if we don't have one.
+ if ( !$hasError && !$email ) {
+ $email = $firstNonEmptyEmail;
}
}
- # Set the $email, if we don't have one.
- if ( !$hasError && !$email ) {
- $email = $firstNonEmptyEmail;
+ else {
+ $hasError = 1;
+ $errResetForbidden = 1;
}
}
else { # 0 matching borrower
errBadEmail => $errBadEmail,
errNoBorrowerEmail => $errNoBorrowerEmail,
errMultipleAccountsForEmail => $errMultipleAccountsForEmail,
+ errResetForbidden => $errResetForbidden,
password_recovery => 1,
email => HTML::Entities::encode($email),
username => $username