Bugzilla – Attachment 138708 Details for
Bug 30646
Add option to send WELCOME notice for new patrons added at first login via LDAP/SAML
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30646: Add welcome email support to LDAP
Bug-30646-Add-welcome-email-support-to-LDAP.patch (text/plain), 4.27 KB, created by
Kyle M Hall (khall)
on 2022-08-05 14:49:40 UTC
(
hide
)
Description:
Bug 30646: Add welcome email support to LDAP
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2022-08-05 14:49:40 UTC
Size:
4.27 KB
patch
obsolete
>From 6730a28f37b57dc497d4499f2cf955faee6b5b5c Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 28 Apr 2022 15:56:55 +0100 >Subject: [PATCH] Bug 30646: Add welcome email support to LDAP > >This patch adds the ability to enable the welcome email notice for new >users added via the LDAP replicate option. > >Test plan >1) Configure LDAP for authentication >2) Enable the welcome email by adding '<welcome>1</welcome>' to your > ldap config block >3) Confirm you have replicate enabled for your LDAP config >4) Attempt to login with an entirely new user to Koha using the LDAP > connection (with a user who has a valid email address mapped to Koha > borrower fields) >5) Confirm the email is sent by looking at the notices for the new user. > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/Auth_with_ldap.pm | 36 +++++++++++++++++++++++++++++++++++- > 1 file changed, 35 insertions(+), 1 deletion(-) > >diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm >index 7f6c99a9a46..915c7a8edfc 100644 >--- a/C4/Auth_with_ldap.pm >+++ b/C4/Auth_with_ldap.pm >@@ -23,6 +23,7 @@ use Carp qw( croak ); > use C4::Context; > use C4::Members::Messaging; > use C4::Auth qw( checkpw_internal ); >+use C4::Letters qw( GetPreparedLetter EnqueueLetter ); > use Koha::Patrons; > use Koha::AuthUtils qw( hash_password ); > use Net::LDAP; >@@ -74,7 +75,8 @@ if(defined $ldap->{categorycode_mapping}) { > my %config = ( > anonymous => defined ($ldap->{anonymous_bind}) ? $ldap->{anonymous_bind} : 1, > replicate => defined($ldap->{replicate}) ? $ldap->{replicate} : 1, # add from LDAP to Koha database for new user >- update => defined($ldap->{update} ) ? $ldap->{update} : 1, # update from LDAP to Koha database for existing user >+ welcome => defined($ldap->{welcome}) ? $ldap->{welcome} : 0, # send welcome notice when patron is added via replicate >+ update => defined($ldap->{update}) ? $ldap->{update} : 1, # update from LDAP to Koha database for existing user > ); > > sub description { >@@ -226,6 +228,37 @@ sub checkpw_ldap { > die "Insert of new patron failed" unless $patron; > $borrowernumber = $patron->borrowernumber; > C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $borrowernumber, categorycode => $borrower{'categorycode'} } ); >+ >+ # Send welcome email if enabled >+ if ( $config{welcome} ) { >+ my $emailaddr = $patron->notice_email_address; >+ >+ # if we manage to find a valid email address, send notice >+ if ($emailaddr) { >+ eval { >+ my $letter = GetPreparedLetter( >+ module => 'members', >+ letter_code => 'WELCOME', >+ branchcode => $patron->branchcode,, >+ lang => $patron->lang || 'default', >+ tables => { >+ 'branches' => $patron->branchcode, >+ 'borrowers' => $patron->borrowernumber, >+ }, >+ want_librarian => 1, >+ ) or return; >+ >+ my $message_id = EnqueueLetter( >+ { >+ letter => $letter, >+ borrowernumber => $patron->id, >+ to_address => $emailaddr, >+ message_transport_type => 'email' >+ } >+ ); >+ }; >+ } >+ } > } else { > return 0; # B2, D2 > } >@@ -508,6 +541,7 @@ Example XML stanza for LDAP configuration in KOHA_CONF. > <user>cn=Manager,dc=metavore,dc=com</user> <!-- DN, if not anonymous --> > <pass>metavore</pass> <!-- password, if not anonymous --> > <replicate>1</replicate> <!-- add new users from LDAP to Koha database --> >+ <welcome>1</welcome> <!-- send new users the welcome email when added via replicate --> > <update>1</update> <!-- update existing users in Koha database --> > <auth_by_bind>0</auth_by_bind> <!-- set to 1 to authenticate by binding instead of > password comparison, e.g., to use Active Directory --> >-- >2.30.2
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 30646
:
134272
|
134279
|
136171
|
136172
|
136173
|
138708
|
138709
|
138710
|
141117
|
141118
|
141119
|
141120
|
141121