Bugzilla – Attachment 85390 Details for
Bug 10796
Allow password changes for logged in OPAC users by patron category
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10796: Add Koha::Patron::Category->effective_change_password method
Bug-10796-Add-KohaPatronCategory-effectivechangepa.patch (text/plain), 3.95 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-02-20 17:09:50 UTC
(
hide
)
Description:
Bug 10796: Add Koha::Patron::Category->effective_change_password method
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-02-20 17:09:50 UTC
Size:
3.95 KB
patch
obsolete
>From 66157d5cb636eaab6a761e937d17049b5fe3e4f8 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 20 Feb 2019 13:26:18 -0300 >Subject: [PATCH] Bug 10796: Add > Koha::Patron::Category->effective_change_password method > >This method checks whether the local $self->change_password is set to >override the OpacPasswordChange syspref (i.e. if it is set to a >bool) or undef, in which case it falls back to the value of the syspref > >To test: >- Apply this patches >- Make sure the DB is updated: > $ updatedatabase >- Update the schema files: > $ dbic >- Run: > $ kshell > k$ prove t/db_dependent/Koha/Patron/Category.t >=> SUCCESS: Tests pass! >- Sign off :-D >--- > Koha/Patron/Category.pm | 15 +++++++ > t/db_dependent/Koha/Patron/Category.t | 60 ++++++++++++++++++++++++++- > 2 files changed, 74 insertions(+), 1 deletion(-) > >diff --git a/Koha/Patron/Category.pm b/Koha/Patron/Category.pm >index f614d5b0bc..261b232d33 100644 >--- a/Koha/Patron/Category.pm >+++ b/Koha/Patron/Category.pm >@@ -239,6 +239,21 @@ sub effective_reset_password { > : C4::Context->preference('OpacResetPassword'); > } > >+=head3 effective_change_password >+ >+Returns if patrons in this category can change their password. If set in $self->change_password >+or, if undef, falls back to the OpacPasswordChange system preference. >+ >+=cut >+ >+sub effective_change_password { >+ my ($self) = @_; >+ >+ return ( defined $self->change_password ) >+ ? $self->change_password >+ : C4::Context->preference('OpacPasswordChange'); >+} >+ > =head2 Internal methods > > =head3 type >diff --git a/t/db_dependent/Koha/Patron/Category.t b/t/db_dependent/Koha/Patron/Category.t >index 1b4938e9f9..06fe7ecace 100644 >--- a/t/db_dependent/Koha/Patron/Category.t >+++ b/t/db_dependent/Koha/Patron/Category.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 1; >+use Test::More tests => 2; > > use t::lib::TestBuilder; > use t::lib::Mocks; >@@ -86,3 +86,61 @@ subtest 'effective_reset_password() tests' => sub { > $schema->storage->txn_rollback; > }; > }; >+ >+subtest 'effective_change_password() tests' => sub { >+ >+ plan tests => 2; >+ >+ subtest 'specific overrides global' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $category = $builder->build_object({ >+ class => 'Koha::Patron::Categories', >+ value => { >+ change_password => 1 >+ } >+ }); >+ >+ t::lib::Mocks::mock_preference( 'OpacPasswordChange', 0 ); >+ ok( $category->effective_change_password, 'OpacPasswordChange unset, but category has the flag set to 1' ); >+ >+ t::lib::Mocks::mock_preference( 'OpacPasswordChange', 1 ); >+ ok( $category->effective_change_password, 'OpacPasswordChange set and category has the flag set to 1' ); >+ >+ # disable >+ $category->change_password( 0 )->store->discard_changes; >+ >+ t::lib::Mocks::mock_preference( 'OpacPasswordChange', 0 ); >+ ok( !$category->effective_change_password, 'OpacPasswordChange unset, but category has the flag set to 0' ); >+ >+ t::lib::Mocks::mock_preference( 'OpacPasswordChange', 1 ); >+ ok( !$category->effective_change_password, 'OpacPasswordChange set and category has the flag set to 0' ); >+ >+ $schema->storage->txn_rollback; >+ }; >+ >+ subtest 'no specific rule, global applies' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $category = $builder->build_object({ >+ class => 'Koha::Patron::Categories', >+ value => { >+ change_password => undef >+ } >+ }); >+ >+ t::lib::Mocks::mock_preference( 'OpacPasswordChange', 0 ); >+ ok( !$category->effective_change_password, 'OpacPasswordChange set to 0 used' ); >+ >+ t::lib::Mocks::mock_preference( 'OpacPasswordChange', 1 ); >+ ok( $category->effective_change_password, 'OpacPasswordChange set to 1 used' ); >+ >+ $schema->storage->txn_rollback; >+ }; >+}; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 10796
:
85389
|
85390
|
85391
|
85392
|
85393
|
87117
|
87118
|
87119
|
87120
|
87121
|
87296
|
87297
|
87298
|
87299
|
87300