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

(-)a/Koha/Patron.pm (-1 / +37 lines)
Lines 25-34 use JSON qw( to_json ); Link Here
25
use Unicode::Normalize qw( NFKD );
25
use Unicode::Normalize qw( NFKD );
26
26
27
use C4::Context;
27
use C4::Context;
28
use C4::Auth qw( checkpw_hash );
28
use C4::Log qw( logaction );
29
use C4::Log qw( logaction );
29
use Koha::Account;
30
use Koha::Account;
30
use Koha::ArticleRequests;
31
use Koha::ArticleRequests;
31
use C4::Letters;
32
use C4::Letters qw( GetPreparedLetter EnqueueLetter SendQueuedMessages );
32
use Koha::AuthUtils;
33
use Koha::AuthUtils;
33
use Koha::Checkouts;
34
use Koha::Checkouts;
34
use Koha::CirculationRules;
35
use Koha::CirculationRules;
Lines 875-880 sub set_password { Link Here
875
        }
876
        }
876
    }
877
    }
877
878
879
    if ( C4::Context->preference('NotifyPasswordChange') ) {
880
        my $self_from_storage = $self->get_from_storage;
881
        if ( !checkpw_hash( $password, $self_from_storage->password ) ) {
882
            my $emailaddr = $self_from_storage->notice_email_address;
883
884
            # if we manage to find a valid email address, send notice
885
            if ($emailaddr) {
886
                eval {
887
                    my $letter = GetPreparedLetter(
888
                        module      => 'members',
889
                        letter_code => 'PASSCHANGE',
890
                        branchcode  => $self_from_storage->branchcode,
891
                        ,
892
                        lang   => $self_from_storage->lang || 'default',
893
                        tables => {
894
                            'branches'  => $self_from_storage->branchcode,
895
                            'borrowers' => $self_from_storage->borrowernumber,
896
                        },
897
                        want_librarian => 1,
898
                    ) or return;
899
900
                    my $message_id = EnqueueLetter(
901
                        {
902
                            letter                 => $letter,
903
                            borrowernumber         => $self_from_storage->id,
904
                            to_address             => $emailaddr,
905
                            message_transport_type => 'email'
906
                        }
907
                    );
908
                    SendQueuedMessages( { message_id => $message_id } );
909
                };
910
            }
911
        }
912
    }
913
878
    my $digest = Koha::AuthUtils::hash_password($password);
914
    my $digest = Koha::AuthUtils::hash_password($password);
879
915
880
    # We do not want to call $self->store and retrieve password from DB
916
    # We do not want to call $self->store and retrieve password from DB
(-)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 1024-1029 tables: Link Here
1024
            - ""
1024
            - ""
1025
            - "If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly."
1025
            - "If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly."
1026
1026
1027
        - module: members
1028
          code: PASSCHANGE
1029
          branchcode: ""
1030
          name: "Notification of password change"
1031
          is_html: 1
1032
          title: "Library account password change notification for [% patron.firstname %] [% patron.surname %]"
1033
          message_transport_type: email
1034
          lang: default
1035
          content:
1036
            - "Dear [% patron.firstname %] [% patron.surname %],"
1037
            - ""
1038
            - "Someone has changed your library user account password."
1039
            - ""
1040
            - "If this is unexpected, please contact the library"
1041
1027
        - module: members
1042
        - module: members
1028
          code: PASSWORD_RESET
1043
          code: PASSWORD_RESET
1029
          branchcode: ""
1044
          branchcode: ""
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 365-370 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
365
('NoticeCSS','',NULL,'Notices CSS url.','free'),
365
('NoticeCSS','',NULL,'Notices CSS url.','free'),
366
('NoticesLog','0',NULL,'If enabled, log changes to notice templates','YesNo'),
366
('NoticesLog','0',NULL,'If enabled, log changes to notice templates','YesNo'),
367
('NotifyBorrowerDeparture','30',NULL,'Define number of days before expiry where circulation is warned about patron account expiry','Integer'),
367
('NotifyBorrowerDeparture','30',NULL,'Define number of days before expiry where circulation is warned about patron account expiry','Integer'),
368
('NotifyPasswordChange','0',NULL,'Notify patrons whenever their password is changed.','YesNo'),
368
('NovelistSelectEnabled','0',NULL,'Enable Novelist Select content.  Requires Novelist Profile and Password','YesNo'),
369
('NovelistSelectEnabled','0',NULL,'Enable Novelist Select content.  Requires Novelist Profile and Password','YesNo'),
369
('NovelistSelectPassword','',NULL,'Novelist select user Password','free'),
370
('NovelistSelectPassword','',NULL,'Novelist select user Password','free'),
370
('NovelistSelectProfile','',NULL,'Novelist Select user Profile','free'),
371
('NovelistSelectProfile','',NULL,'Novelist Select user Profile','free'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (-1 / +6 lines)
Lines 148-153 Patrons: Link Here
148
               1: Send
148
               1: Send
149
               0: "Don't send"
149
               0: "Don't send"
150
         - an email to newly created patrons with their account details.
150
         - an email to newly created patrons with their account details.
151
     -
152
         - pref: NotifyPasswordChange
153
           choices:
154
               1: Notify
155
               0: "Don't notify"
156
         - patrons whenever their password is changed.
151
     -
157
     -
152
         - pref: UseEmailReceipts
158
         - pref: UseEmailReceipts
153
           choices:
159
           choices:
154
- 

Return to bug 25936