Bug 30646 - Add option to send WELCOME notice for new patrons added at first login via LDAP/SAML
Summary: Add option to send WELCOME notice for new patrons added at first login via LD...
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Martin Renvoize
QA Contact: Tomás Cohen Arazi
URL:
Keywords:
Depends on: 30237
Blocks:
  Show dependency treegraph
 
Reported: 2022-04-28 14:19 UTC by Martin Renvoize
Modified: 2023-12-28 20:43 UTC (History)
10 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact: Caroline Cyr La Rose
Documentation submission: https://gitlab.com/koha-community/koha-manual/-/merge_requests/679
Text to go in the release notes:
When LDAP or Shibboleth are used to create user accounts on first login, the WELCOME notice can be send automatically to the new users. This requires adding the new configuration option <welcome>1</welcome> to the respective configuration files.
Version(s) released in:
22.11.00


Attachments
Bug 30646: Add welcome email support to LDAP (4.22 KB, patch)
2022-04-28 15:02 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 30646: Add welcome email support to SAML2 (3.01 KB, patch)
2022-04-28 15:14 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 30646: Add welcome email support to LDAP (4.22 KB, patch)
2022-06-16 14:24 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 30646: Add welcome email support to SAML2 (3.01 KB, patch)
2022-06-16 14:24 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 30646: (follow-up) Set to send immediately (3.20 KB, patch)
2022-06-16 14:24 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 30646: Add welcome email support to LDAP (4.27 KB, patch)
2022-08-05 14:49 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 30646: Add welcome email support to SAML2 (3.06 KB, patch)
2022-08-05 14:50 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 30646: (follow-up) Set to send immediately (3.25 KB, patch)
2022-08-05 14:50 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 30646: Add welcome email support to LDAP (4.42 KB, patch)
2022-09-30 10:46 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 30646: Add welcome email support to SAML2 (2.97 KB, patch)
2022-09-30 10:46 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 30646: (follow-up) Set to send immediately (2.02 KB, patch)
2022-09-30 10:46 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 30646: Unit test for Auth_with_shibboleth (5.26 KB, patch)
2022-09-30 10:46 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 30646: Unit tests for Auth_with_ldap (4.03 KB, patch)
2022-09-30 10:47 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize 2022-04-28 14:19:46 UTC
It would be helpful to add automatic email to users on patron creation when that creation has been triggered by LDAP or Shibboleth creations.
Comment 1 Martin Renvoize 2022-04-28 15:02:28 UTC
Created attachment 134272 [details] [review]
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.
Comment 2 Martin Renvoize 2022-04-28 15:14:50 UTC
Created attachment 134279 [details] [review]
Bug 30646: Add welcome email support to SAML2

This patch adds the ability to enable the welcome email notice for new
users added via the Shibboleth autocreate option.

Test plan
1) Configure Shibboleth for authentication
2) Enable the welcome email by adding '<welcome>1</welcome>' to your
   shibboleth config block
3) Confirm you have autocreate enabled for your Shibboleth config
4) Attempt to login with an entirely new user to Koha using the shibboleth
   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.
Comment 3 Martin Renvoize 2022-06-16 14:24:26 UTC
Created attachment 136171 [details] [review]
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.
Comment 4 Martin Renvoize 2022-06-16 14:24:30 UTC
Created attachment 136172 [details] [review]
Bug 30646: Add welcome email support to SAML2

This patch adds the ability to enable the welcome email notice for new
users added via the Shibboleth autocreate option.

Test plan
1) Configure Shibboleth for authentication
2) Enable the welcome email by adding '<welcome>1</welcome>' to your
   shibboleth config block
3) Confirm you have autocreate enabled for your Shibboleth config
4) Attempt to login with an entirely new user to Koha using the shibboleth
   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.
Comment 5 Martin Renvoize 2022-06-16 14:24:34 UTC
Created attachment 136173 [details] [review]
Bug 30646: (follow-up) Set to send immediately

Other welcome notices send immediately rather than waiting on the queue
to be processed.. these one's should too.
Comment 6 Kyle M Hall 2022-08-05 14:49:40 UTC
Created attachment 138708 [details] [review]
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>
Comment 7 Kyle M Hall 2022-08-05 14:50:17 UTC
Created attachment 138709 [details] [review]
Bug 30646: Add welcome email support to SAML2

This patch adds the ability to enable the welcome email notice for new
users added via the Shibboleth autocreate option.

Test plan
1) Configure Shibboleth for authentication
2) Enable the welcome email by adding '<welcome>1</welcome>' to your
   shibboleth config block
3) Confirm you have autocreate enabled for your Shibboleth config
4) Attempt to login with an entirely new user to Koha using the shibboleth
   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>
Comment 8 Kyle M Hall 2022-08-05 14:50:21 UTC
Created attachment 138710 [details] [review]
Bug 30646: (follow-up) Set to send immediately

Other welcome notices send immediately rather than waiting on the queue
to be processed.. these one's should too.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 9 Martin Renvoize 2022-09-23 13:54:27 UTC
Hmm.. we now have this running in production.. May I convert your SO to a QA and add our customers name as an SO Kyle?
Comment 10 Tomás Cohen Arazi 2022-09-23 14:16:24 UTC
This all looks good, but we need tests:

- Mocked test on GetPreparedLetter being called and then EnqueueLetter as well
- Mocked test on SendQueuedMessages being called with the right parameter
- Not super picky about it, but $patron->notice_email_address should also be tested.

Can try helping, but not today.
Comment 11 Martin Renvoize 2022-09-30 10:46:43 UTC
Created attachment 141117 [details] [review]
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>
Comment 12 Martin Renvoize 2022-09-30 10:46:48 UTC
Created attachment 141118 [details] [review]
Bug 30646: Add welcome email support to SAML2

This patch adds the ability to enable the welcome email notice for new
users added via the Shibboleth autocreate option.

Test plan
1) Configure Shibboleth for authentication
2) Enable the welcome email by adding '<welcome>1</welcome>' to your
   shibboleth config block
3) Confirm you have autocreate enabled for your Shibboleth config
4) Attempt to login with an entirely new user to Koha using the shibboleth
   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>
Comment 13 Martin Renvoize 2022-09-30 10:46:52 UTC
Created attachment 141119 [details] [review]
Bug 30646: (follow-up) Set to send immediately

Other welcome notices send immediately rather than waiting on the queue
to be processed.. these one's should too.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 14 Martin Renvoize 2022-09-30 10:46:56 UTC
Created attachment 141120 [details] [review]
Bug 30646: Unit test for Auth_with_shibboleth

This patch adds a unit test for the Auth_with_shibboleth welcome notice
addition.
Comment 15 Martin Renvoize 2022-09-30 10:47:00 UTC
Created attachment 141121 [details] [review]
Bug 30646: Unit tests for Auth_with_ldap

This patch adds a unit test to the Auth_with_ldap.t to confirm welcome
notices are send when replace + welcome are enabled in the
configuration.

We also add a snippet to hide 'Subroutine redefined' warnings in this
test as it makes the test output rather challenging to read and the way
the test is written these warning are expected.
Comment 16 Martin Renvoize 2022-09-30 10:48:51 UTC
One day I'll get around to re-writing/re-factoring those tests.. they're a nightmare to work on.

Anywho, tests now submitted, apologies for being bad and not submitting earlier :(.

Note.. I snuck in a snippet to quiten the plethora of warning that the Auth_with_ldap.t test was throwing.. it's well documented in the top of the test now and makes the test output sooooo much more readable.
Comment 17 Tomás Cohen Arazi 2022-10-03 17:14:46 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!