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

(-)a/Koha/Patron.pm (-1 / +35 lines)
Lines 26-35 use Unicode::Normalize qw( NFKD ); Link Here
26
use Try::Tiny;
26
use Try::Tiny;
27
27
28
use C4::Context;
28
use C4::Context;
29
use C4::Auth qw( checkpw_hash );
29
use C4::Log qw( logaction );
30
use C4::Log qw( logaction );
30
use Koha::Account;
31
use Koha::Account;
31
use Koha::ArticleRequests;
32
use Koha::ArticleRequests;
32
use C4::Letters;
33
use C4::Letters qw( GetPreparedLetter EnqueueLetter SendQueuedMessages );
33
use Koha::AuthUtils;
34
use Koha::AuthUtils;
34
use Koha::Checkouts;
35
use Koha::Checkouts;
35
use Koha::CirculationRules;
36
use Koha::CirculationRules;
Lines 889-894 sub set_password { Link Here
889
        }
890
        }
890
    }
891
    }
891
892
893
    if ( C4::Context->preference('NotifyPasswordChange') ) {
894
        my $self_from_storage = $self->get_from_storage;
895
        if ( !C4::Auth::checkpw_hash( $password, $self_from_storage->password ) ) {
896
            my $emailaddr = $self_from_storage->notice_email_address;
897
898
            # if we manage to find a valid email address, send notice
899
            if ($emailaddr) {
900
                my $letter = C4::Letters::GetPreparedLetter(
901
                    module      => 'members',
902
                    letter_code => 'PASSWORD_CHANGE',
903
                    branchcode  => $self_from_storage->branchcode,
904
                    ,
905
                    lang   => $self_from_storage->lang || 'default',
906
                    tables => {
907
                        'branches'  => $self_from_storage->branchcode,
908
                        'borrowers' => $self_from_storage->borrowernumber,
909
                    },
910
                    want_librarian => 1,
911
                ) or return;
912
913
                my $message_id = C4::Letters::EnqueueLetter(
914
                    {
915
                        letter                 => $letter,
916
                        borrowernumber         => $self_from_storage->id,
917
                        to_address             => $emailaddr,
918
                        message_transport_type => 'email'
919
                    }
920
                );
921
                C4::Letters::SendQueuedMessages( { message_id => $message_id } );
922
            }
923
        }
924
    }
925
892
    my $digest = Koha::AuthUtils::hash_password($password);
926
    my $digest = Koha::AuthUtils::hash_password($password);
893
927
894
    $self->password_expiration_date( $self->category->get_password_expiry_date || undef );
928
    $self->password_expiration_date( $self->category->get_password_expiry_date || undef );
(-)a/installer/data/mysql/atomicupdate/bug_25936.pl (+27 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "25936",
5
    description => "A password change notification feature",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
10
        # Add PASSCHANGE notice
11
        $dbh->do( q{
12
            INSERT IGNORE INTO letter (module, code, name, title, content, message_transport_type) VALUES ('members', 'PASSCHANGE', 'Notification of password change', 'Library account password change notification',
13
            "Dear [% borrower.firstname %] [% borrower.surname %],
14
15
            Someone has changed your library user account password.
16
17
            If this is unexpected, please contact the library.
18
            ", 'email');
19
        });
20
21
        # Add systempreference
22
        $dbh->do(q{
23
            INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
24
            VALUES ('NotifyPasswordChange','0','','Notify patrons whenever their password is changed.','YesNo')
25
        });
26
    },
27
};
(-)a/installer/data/mysql/en/mandatory/sample_notices.yml (+15 lines)
Lines 1076-1081 tables: Link Here
1076
            - ""
1076
            - ""
1077
            - "If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly."
1077
            - "If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly."
1078
1078
1079
        - module: members
1080
          code: PASSCHANGE
1081
          branchcode: ""
1082
          name: "Notification of password change"
1083
          is_html: 1
1084
          title: "Library account password change notification for [% patron.firstname %] [% patron.surname %]"
1085
          message_transport_type: email
1086
          lang: default
1087
          content:
1088
            - "Dear [% patron.firstname %] [% patron.surname %],"
1089
            - ""
1090
            - "Someone has changed your library user account password."
1091
            - ""
1092
            - "If this is unexpected, please contact the library"
1093
1079
        - module: members
1094
        - module: members
1080
          code: PASSWORD_RESET
1095
          code: PASSWORD_RESET
1081
          branchcode: ""
1096
          branchcode: ""
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 386-391 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
386
('NoticeCSS','',NULL,'Notices CSS url.','free'),
386
('NoticeCSS','',NULL,'Notices CSS url.','free'),
387
('NoticesLog','0',NULL,'If enabled, log changes to notice templates','YesNo'),
387
('NoticesLog','0',NULL,'If enabled, log changes to notice templates','YesNo'),
388
('NotifyBorrowerDeparture','30',NULL,'Define number of days before expiry where circulation is warned about patron account expiry','Integer'),
388
('NotifyBorrowerDeparture','30',NULL,'Define number of days before expiry where circulation is warned about patron account expiry','Integer'),
389
('NotifyPasswordChange','0',NULL,'Notify patrons whenever their password is changed.','YesNo'),
389
('NovelistSelectEnabled','0',NULL,'Enable Novelist Select content.  Requires Novelist Profile and Password','YesNo'),
390
('NovelistSelectEnabled','0',NULL,'Enable Novelist Select content.  Requires Novelist Profile and Password','YesNo'),
390
('NovelistSelectPassword','',NULL,'Novelist select user Password','free'),
391
('NovelistSelectPassword','',NULL,'Novelist select user Password','free'),
391
('NovelistSelectProfile','',NULL,'Novelist Select user Profile','free'),
392
('NovelistSelectProfile','',NULL,'Novelist Select user Profile','free'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (-1 / +6 lines)
Lines 160-165 Patrons: Link Here
160
               0: "Don't send"
160
               0: "Don't send"
161
         - an email to newly created patrons.
161
         - an email to newly created patrons.
162
         - '<br><strong>NOTE:</strong> This uses the WELCOME notice.'
162
         - '<br><strong>NOTE:</strong> This uses the WELCOME notice.'
163
     -
164
         - pref: NotifyPasswordChange
165
           choices:
166
               1: Notify
167
               0: "Don't notify"
168
         - patrons whenever their password is changed.
163
     -
169
     -
164
         - pref: UseEmailReceipts
170
         - pref: UseEmailReceipts
165
           choices:
171
           choices:
166
- 

Return to bug 25936