View | Details | Raw Unified | Return to bug 22706
Collapse All | Expand All

(-)a/Koha/Exceptions/Password.pm (-1 / +5 lines)
Lines 38-44 use Exception::Class ( Link Here
38
    'Koha::Exceptions::Password::WhitespaceCharacters' => {
38
    'Koha::Exceptions::Password::WhitespaceCharacters' => {
39
        isa => 'Koha::Exceptions::Password',
39
        isa => 'Koha::Exceptions::Password',
40
        description => 'Password contains leading/trailing whitespace character(s)'
40
        description => 'Password contains leading/trailing whitespace character(s)'
41
    }
41
    },
42
    'Koha::Exceptions::Password::Plugin' => {
43
        isa => 'Koha::Exceptions::Password',
44
        description => 'The password was rejected by a plugin'
45
    },
42
);
46
);
43
47
44
sub full_message {
48
sub full_message {
(-)a/Koha/Patron.pm (-3 / +56 lines)
Lines 43-48 use Koha::Patron::HouseboundRole; Link Here
43
use Koha::Patron::Images;
43
use Koha::Patron::Images;
44
use Koha::Patron::Relationships;
44
use Koha::Patron::Relationships;
45
use Koha::Patrons;
45
use Koha::Patrons;
46
use Koha::Plugins;
47
use Koha::Plugins::Handler;
46
use Koha::Subscription::Routinglists;
48
use Koha::Subscription::Routinglists;
47
use Koha::Token;
49
use Koha::Token;
48
use Koha::Virtualshelves;
50
use Koha::Virtualshelves;
Lines 223-232 sub store { Link Here
223
                  :                                                   undef;
225
                  :                                                   undef;
224
                $self->privacy($default_privacy);
226
                $self->privacy($default_privacy);
225
227
226
227
                # Make a copy of the plain text password for later use
228
                # Make a copy of the plain text password for later use
228
                $self->plain_text_password( $self->password );
229
                $self->plain_text_password( $self->password );
229
230
231
                logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" )
232
                  if C4::Context->preference("BorrowersLog");
233
234
                if ( C4::Context->preference('UseKohaPlugins') && C4::Context->config("enable_plugins") ) {
235
                    # Call any check_password plugins
236
                    my @plugins = Koha::Plugins->new()->GetPlugins({
237
                        method => 'check_password',
238
                    });
239
                    foreach my $plugin ( @plugins ) {
240
                        # This plugin hook will also be used by a plugin for the Norwegian national
241
                        # patron database. This is why we need to pass both the password and the
242
                        # borrowernumber to the plugin.
243
                        my $ret = Koha::Plugins::Handler->run({
244
                            class  => ref $plugin,
245
                            method => 'check_password',
246
                            params => {
247
                                password       => $self->plain_text_password,
248
                                borrowernumber => $self->borrowernumber,
249
                            },
250
                        });
251
                        if ( $ret->{'error'} == 1 ) {
252
                            Koha::Exceptions::Password::Plugin->throw();
253
                        }
254
                    }
255
                }
256
230
                # Create a disabled account if no password provided
257
                # Create a disabled account if no password provided
231
                $self->password( $self->password
258
                $self->password( $self->password
232
                    ? Koha::AuthUtils::hash_password( $self->password )
259
                    ? Koha::AuthUtils::hash_password( $self->password )
Lines 238-245 sub store { Link Here
238
265
239
                $self->add_enrolment_fee_if_needed(0);
266
                $self->add_enrolment_fee_if_needed(0);
240
267
241
                logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" )
242
                  if C4::Context->preference("BorrowersLog");
243
            }
268
            }
244
            else {    #ModMember
269
            else {    #ModMember
245
270
Lines 682-687 Exceptions are thrown if the password is not good enough. Link Here
682
707
683
=item Koha::Exceptions::Password::TooWeak
708
=item Koha::Exceptions::Password::TooWeak
684
709
710
=item Koha::Exceptions::Password::Plugin (if a "check password" plugin is enabled)
711
685
=back
712
=back
686
713
687
=cut
714
=cut
Lines 712-717 sub set_password { Link Here
712
        }
739
        }
713
    }
740
    }
714
741
742
    if ( C4::Context->preference('UseKohaPlugins') && C4::Context->config("enable_plugins") ) {
743
        # Call any check_password plugins
744
        my @plugins = Koha::Plugins->new()->GetPlugins({
745
            method => 'check_password',
746
        });
747
        foreach my $plugin ( @plugins ) {
748
            # This plugin hook will also be used by a plugin for the Norwegian national
749
            # patron database. This is why we need to pass both the password and the
750
            # borrowernumber to the plugin.
751
            my $ret = Koha::Plugins::Handler->run({
752
                class  => ref $plugin,
753
                method => 'check_password',
754
                params => {
755
                    password       => $password,
756
                    borrowernumber => $self->borrowernumber,
757
                },
758
            });
759
            # This plugin hook will also be used by a plugin for the Norwegian national
760
            # patron database. This is why we need to call the actual plugins and then
761
            # check skip_validation afterwards.
762
            if ( $ret->{'error'} == 1 && !$args->{skip_validation} ) {
763
                Koha::Exceptions::Password::Plugin->throw();
764
            }
765
        }
766
    }
767
715
    my $digest = Koha::AuthUtils::hash_password($password);
768
    my $digest = Koha::AuthUtils::hash_password($password);
716
    $self->update(
769
    $self->update(
717
        {   password       => $digest,
770
        {   password       => $digest,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member-password.tt (+3 lines)
Lines 44-49 Link Here
44
        [% END %]
44
        [% END %]
45
        [% IF ( ERROR_password_has_whitespaces ) %]
45
        [% IF ( ERROR_password_has_whitespaces ) %]
46
            <li id="ERROR_weak_password">Password must not contain leading or trailing whitespaces.</li>
46
            <li id="ERROR_weak_password">Password must not contain leading or trailing whitespaces.</li>
47
        [% END %]
48
        [% IF ( ERROR_from_plugin ) %]
49
            <li id="ERROR_from_plugin">The password was rejected by a plugin.</li>
47
        [% END %]
50
        [% END %]
48
		[% IF ( NOPERMISSION ) %]
51
		[% IF ( NOPERMISSION ) %]
49
		<li>You do not have permission to edit this patron's login information.</li>
52
		<li>You do not have permission to edit this patron's login information.</li>
(-)a/members/member-password.pl (-1 / +3 lines)
Lines 91-96 if ( $newpassword and not @errors) { Link Here
91
        elsif ( $_->isa('Koha::Exceptions::Password::TooWeak') ) {
91
        elsif ( $_->isa('Koha::Exceptions::Password::TooWeak') ) {
92
            push @errors, 'ERROR_password_too_weak';
92
            push @errors, 'ERROR_password_too_weak';
93
        }
93
        }
94
        elsif ( $_->isa('Koha::Exceptions::Password::Plugin') ) {
95
            push @errors, 'ERROR_from_plugin';
96
        }
94
        else {
97
        else {
95
            push( @errors, 'BADUSERID' );
98
            push( @errors, 'BADUSERID' );
96
        }
99
        }
97
- 

Return to bug 22706