From 652c627314142d5b26606dbee7220726cbdedb61 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 25 Jan 2017 16:15:32 +0100 Subject: [PATCH] Revert "Bug 17494: Prevent duplicate tokens from getting stored" This reverts commit 8156e86a3050773b1e9741650a93a3b5773bb810. --- Koha/AudioAlert.pm | 21 +------------------- Koha/Exceptions/Patron/Modification.pm | 12 ----------- opac/opac-memberentry.pl | 5 ----- t/db_dependent/Koha_borrower_modifications.t | 20 ++----------------- 4 files changed, 3 insertions(+), 55 deletions(-) delete mode 100644 Koha/Exceptions/Patron/Modification.pm diff --git a/Koha/AudioAlert.pm b/Koha/AudioAlert.pm index d86d9a17f0..e23e46b534 100644 --- a/Koha/AudioAlert.pm +++ b/Koha/AudioAlert.pm @@ -23,9 +23,6 @@ use Carp; use Koha::Database; -use Koha::Patron::Modifications; -use Koha::Exceptions::Patron::Modification; - use base qw(Koha::Object); =head1 NAME @@ -34,23 +31,7 @@ Koha::AudioAlert - Koha Audio Alert object class =head1 API -=head2 store - -=cut - -sub store { - my ($self) = @_; - - if ( $self->verification_token ) { - if ( Koha::Patron::Modifications->search( { verification_token => $self->verification_token } )->count() ) { - Koha::Exceptions::Koha::Patron::Modification::DuplicateVerificationToken->throw; - } - } - - return $self->SUPER::store(); -} - -=head2 approve +=head2 Class Methods =head3 store diff --git a/Koha/Exceptions/Patron/Modification.pm b/Koha/Exceptions/Patron/Modification.pm deleted file mode 100644 index 1068fbb549..0000000000 --- a/Koha/Exceptions/Patron/Modification.pm +++ /dev/null @@ -1,12 +0,0 @@ -package Koha::Exceptions::Patron::Modification; - -use Modern::Perl; - -use Exception::Class ( - 'Koha::Exceptions::Koha::Patron::Modification::DuplicateVerificationToken' => { - isa => 'Koha::Exceptions::Object', - description => "The verification token given already exists", - }, -); - -1; diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 86e7f4557f..f590336e93 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -111,11 +111,6 @@ if ( $action eq 'create' ) { $template->param( 'email' => $borrower{'email'} ); my $verification_token = md5_hex( time().{}.rand().{}.$$ ); - - while ( Koha::Patron::Modifications->search( { verification_token => $verification_token } )->count() ) { - $verification_token = md5_hex( time().{}.rand().{}.$$ ); - } - $borrower{'password'} = random_string(".........."); Koha::Borrower::Modifications->new( diff --git a/t/db_dependent/Koha_borrower_modifications.t b/t/db_dependent/Koha_borrower_modifications.t index ad16d387c0..e2ab5f522a 100755 --- a/t/db_dependent/Koha_borrower_modifications.t +++ b/t/db_dependent/Koha_borrower_modifications.t @@ -1,12 +1,10 @@ #!/usr/bin/perl use Modern::Perl; -use Test::More tests => 15; -use Try::Tiny; - -use t::lib::TestBuilder; +use Test::More tests => 14; use C4::Context; +use t::lib::TestBuilder; use C4::Members; use Koha::Borrower::Modifications; @@ -21,20 +19,6 @@ $dbh->do("DELETE FROM borrower_modifications"); Koha::Borrower::Modifications->new( verification_token => '1234567890' ) ->AddModifications( { surname => 'Hall', firstname => 'Kyle' } ); -## Ensure duplicate verification tokens cannot be added to the database -try { - Koha::Patron::Modification->new( - { - verification_token => '1234567890', - surname => 'Hall', - firstname => 'Daria' - } - )->store(); -} catch { - ok( $_->isa('Koha::Exceptions::Koha::Patron::Modification::DuplicateVerificationToken'), - 'Attempting to add a duplicate verification token to the database should raise a Koha::Exceptions::Koha::Patron::Modification::DuplicateVerificationToken exception' ); -}; - ## Get the new pending modification my $borrower = Koha::Borrower::Modifications->GetModifications( { verification_token => '1234567890' } ); -- 2.39.5