|
Lines 69-74
use Koha::Result::Boolean;
Link Here
|
| 69 |
use Koha::Subscription::Routinglists; |
69 |
use Koha::Subscription::Routinglists; |
| 70 |
use Koha::Token; |
70 |
use Koha::Token; |
| 71 |
use Koha::Virtualshelves; |
71 |
use Koha::Virtualshelves; |
|
|
72 |
use Koha::PatronPasswordHistory; |
| 73 |
use Koha::PatronPasswordHistories; |
| 72 |
|
74 |
|
| 73 |
use base qw(Koha::Object); |
75 |
use base qw(Koha::Object); |
| 74 |
|
76 |
|
|
Lines 1062-1067
sub set_password {
Link Here
|
| 1062 |
my $action = $args->{action} || "CHANGE PASS"; |
1064 |
my $action = $args->{action} || "CHANGE PASS"; |
| 1063 |
|
1065 |
|
| 1064 |
unless ( $args->{skip_validation} ) { |
1066 |
unless ( $args->{skip_validation} ) { |
|
|
1067 |
# Check password history first |
| 1068 |
if (Koha::PatronPasswordHistories->has_used_password({ |
| 1069 |
borrowernumber => $self->borrowernumber, |
| 1070 |
password => $password, |
| 1071 |
current_password => $self->password |
| 1072 |
})) { |
| 1073 |
Koha::Exceptions::Password::UsedBefore->throw( |
| 1074 |
error => 'Password has been used before' |
| 1075 |
); |
| 1076 |
} |
| 1077 |
|
| 1065 |
my ( $is_valid, $error ) = Koha::AuthUtils::is_password_valid( $password, $self->category ); |
1078 |
my ( $is_valid, $error ) = Koha::AuthUtils::is_password_valid( $password, $self->category ); |
| 1066 |
|
1079 |
|
| 1067 |
if ( !$is_valid ) { |
1080 |
if ( !$is_valid ) { |
|
Lines 1143-1148
sub set_password {
Link Here
|
| 1143 |
} |
1156 |
} |
| 1144 |
} |
1157 |
} |
| 1145 |
|
1158 |
|
|
|
1159 |
# Store old password in history if there is one and it's different from the new one |
| 1160 |
if ($self->password && $self->in_storage) { |
| 1161 |
# Get the old password before it's replaced |
| 1162 |
my $old_password = $self->get_from_storage->password; |
| 1163 |
my $history_count = C4::Context->preference('PasswordHistoryCount') || 0; |
| 1164 |
|
| 1165 |
# Always store the old password, regardless of current preference |
| 1166 |
# This ensures we maintain history if the preference is increased later |
| 1167 |
my $history_record = Koha::PatronPasswordHistory->new({ |
| 1168 |
borrowernumber => $self->borrowernumber, |
| 1169 |
password => $old_password, |
| 1170 |
})->store(); |
| 1171 |
} |
| 1172 |
|
| 1146 |
my $digest = Koha::AuthUtils::hash_password($password); |
1173 |
my $digest = Koha::AuthUtils::hash_password($password); |
| 1147 |
|
1174 |
|
| 1148 |
$self->password_expiration_date( $self->category->get_password_expiry_date || undef ); |
1175 |
$self->password_expiration_date( $self->category->get_password_expiry_date || undef ); |
| 1149 |
- |
|
|