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 (-1 / +45 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-229 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
Lines 240-245 sub store { Link Here
240
241
241
                logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" )
242
                logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" )
242
                  if C4::Context->preference("BorrowersLog");
243
                  if C4::Context->preference("BorrowersLog");
244
245
                if ( C4::Context->preference('UseKohaPlugins') && C4::Context->config("enable_plugins") ) {
246
                    # Call any check_password plugins
247
                    my @plugins = Koha::Plugins->new()->GetPlugins({
248
                        method => 'check_password',
249
                    });
250
                    foreach my $plugin ( @plugins ) {
251
                        my $ret = Koha::Plugins::Handler->run({
252
                            class  => ref $plugin,
253
                            method => 'check_password',
254
                            params => {
255
                                password       => $self->plain_text_password,
256
                                borrowernumber => $self->borrowernumber,
257
                            },
258
                        });
259
                        if ( $ret->{'error'} == 1 ) {
260
                            Koha::Exceptions::Password::Plugin->throw();
261
                        }
262
                    }
263
                }
264
243
            }
265
            }
244
            else {    #ModMember
266
            else {    #ModMember
245
267
Lines 682-687 Exceptions are thrown if the password is not good enough. Link Here
682
704
683
=item Koha::Exceptions::Password::TooWeak
705
=item Koha::Exceptions::Password::TooWeak
684
706
707
=item Koha::Exceptions::Password::Plugin (if a "check password" plugin is enabled)
708
685
=back
709
=back
686
710
687
=cut
711
=cut
Lines 712-717 sub set_password { Link Here
712
        }
736
        }
713
    }
737
    }
714
738
739
    if ( C4::Context->preference('UseKohaPlugins') && C4::Context->config("enable_plugins") ) {
740
        # Call any check_password plugins
741
        my @plugins = Koha::Plugins->new()->GetPlugins({
742
            method => 'check_password',
743
        });
744
        foreach my $plugin ( @plugins ) {
745
            my $ret = Koha::Plugins::Handler->run({
746
                class  => ref $plugin,
747
                method => 'check_password',
748
                params => {
749
                    password       => $password,
750
                    borrowernumber => $self->borrowernumber,
751
                },
752
            });
753
            if ( $ret->{'error'} == 1 ) {
754
                Koha::Exceptions::Password::Plugin->throw();
755
            }
756
        }
757
    }
758
715
    my $digest = Koha::AuthUtils::hash_password($password);
759
    my $digest = Koha::AuthUtils::hash_password($password);
716
    $self->update(
760
    $self->update(
717
        {   password       => $digest,
761
        {   password       => $digest,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member-password.tt (+3 lines)
Lines 45-50 Link Here
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 %]
47
        [% END %]
48
        [% IF ( ERROR_from_plugin ) %]
49
            <li id="ERROR_from_plugin">The password was rejected by a plugin.</li>
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>
50
		[% END %]
53
		[% END %]
(-)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