Bug 21992: Remove unused Koha::Patron->update_password method
This patch removes the no longer used method. To test: - Apply this patch - Run: $ git grep update_password => SUCCESS: Only references are in Auth_with_ldap.pm and not related - Sign off :-D Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
197a7029f6
commit
03ea0f0b37
|
|
@ -276,7 +276,7 @@ sub store {
|
|||
$self->userid($stored_userid);
|
||||
}
|
||||
|
||||
# Password must be updated using $self->update_password
|
||||
# Password must be updated using $self->set_password
|
||||
$self->password($self_from_storage->password);
|
||||
|
||||
if ( C4::Context->preference('FeeOnChangePatronCategory')
|
||||
|
|
@ -639,35 +639,6 @@ sub is_going_to_expire {
|
|||
return 0;
|
||||
}
|
||||
|
||||
=head3 update_password
|
||||
|
||||
my $updated = $patron->update_password( $userid, $password );
|
||||
|
||||
Update the userid and the password of a patron.
|
||||
If the userid already exists, returns and let DBIx::Class warns
|
||||
This will add an entry to action_logs if BorrowersLog is set.
|
||||
|
||||
=cut
|
||||
|
||||
sub update_password {
|
||||
my ( $self, $userid, $password ) = @_;
|
||||
eval { $self->userid($userid)->store; };
|
||||
return if $@; # Make sure the userid is not already in used by another patron
|
||||
|
||||
return 0 if $password eq '****' or $password eq '';
|
||||
|
||||
my $digest = Koha::AuthUtils::hash_password($password);
|
||||
$self->update(
|
||||
{
|
||||
password => $digest,
|
||||
login_attempts => 0,
|
||||
}
|
||||
);
|
||||
|
||||
logaction( "MEMBERS", "CHANGE PASS", $self->borrowernumber, "" ) if C4::Context->preference("BorrowersLog");
|
||||
return $digest;
|
||||
}
|
||||
|
||||
=head3 set_password
|
||||
|
||||
$patron->set_password({ password => $plain_text_password [, skip_validation => 1 ] });
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 34;
|
||||
use Test::More tests => 33;
|
||||
use Test::Warn;
|
||||
use Test::Exception;
|
||||
use Test::MockModule;
|
||||
|
|
@ -207,31 +207,6 @@ subtest 'has_overdues' => sub {
|
|||
$issue->delete();
|
||||
};
|
||||
|
||||
subtest 'update_password' => sub {
|
||||
plan tests => 7;
|
||||
|
||||
t::lib::Mocks::mock_preference( 'BorrowersLog', 1 );
|
||||
my $original_userid = $new_patron_1->userid;
|
||||
my $original_password = $new_patron_1->password;
|
||||
warning_like { $retrieved_patron_1->update_password( $new_patron_2->userid, 'another_password' ) }
|
||||
qr{Duplicate entry},
|
||||
'Koha::Patron->update_password should warn if the userid is already used by another patron';
|
||||
is( Koha::Patrons->find( $new_patron_1->borrowernumber )->userid, $original_userid, 'Koha::Patron->update_password should not have updated the userid' );
|
||||
is( Koha::Patrons->find( $new_patron_1->borrowernumber )->password, $original_password, 'Koha::Patron->update_password should not have updated the userid' );
|
||||
|
||||
my $digest = $retrieved_patron_1->update_password( 'another_nonexistent_userid_1', 'another_password' );
|
||||
is( Koha::Patrons->find( $new_patron_1->borrowernumber )->userid, 'another_nonexistent_userid_1', 'Koha::Patron->update_password should have updated the userid' );
|
||||
is( Koha::Patrons->find( $new_patron_1->borrowernumber )->password, $digest, 'Koha::Patron->update_password should have updated the password' );
|
||||
|
||||
my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'CHANGE PASS', object => $new_patron_1->borrowernumber } )->count;
|
||||
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->update_password should have logged' );
|
||||
|
||||
t::lib::Mocks::mock_preference( 'BorrowersLog', 0 );
|
||||
$retrieved_patron_1->update_password( 'yet_another_nonexistent_userid_1', 'another_password' );
|
||||
$number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'CHANGE PASS', object => $new_patron_1->borrowernumber } )->count;
|
||||
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->update_password should not have logged' );
|
||||
};
|
||||
|
||||
subtest 'is_expired' => sub {
|
||||
plan tests => 4;
|
||||
my $patron = $builder->build({ source => 'Borrower' });
|
||||
|
|
|
|||
Loading…
Reference in New Issue