fix(api): send invite email when creating Portal user (#145)#149
Open
b3lz3but wants to merge 2 commits intocaptainpragmatic:masterfrom
Open
fix(api): send invite email when creating Portal user (#145)#149b3lz3but wants to merge 2 commits intocaptainpragmatic:masterfrom
b3lz3but wants to merge 2 commits intocaptainpragmatic:masterfrom
Conversation
ca9db81 to
42a30bd
Compare
Contributor
Author
|
@mostlyvirtual — this PR is ready for review. |
There was a problem hiding this comment.
Pull request overview
Fixes a Portal onboarding gap where newly created customer users were left with unusable passwords and no invite/reset email, by triggering the existing secure welcome-email flow from both the API endpoint and the staff “Create User” view.
Changes:
- Send password-reset invite email after creating a customer user in
customer_users_create(API) andcustomer_create_user(staff view). - Return
invite_email_sentin the API response and show a staff warning message if email sending fails. - Add new customer welcome email templates (HTML + text) and tests covering success/failure scenarios.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| services/platform/apps/api/customers/views.py | Calls secure welcome-email sender and returns invite_email_sent in response. |
| services/platform/apps/customers/user_management_views.py | Calls secure welcome-email sender; warns staff when email fails. |
| services/platform/templates/customers/emails/welcome_email.txt | Adds plaintext welcome/invite template with reset link. |
| services/platform/templates/customers/emails/welcome_email.html | Adds HTML welcome/invite template with reset link/button. |
| services/platform/tests/api/test_customer_api.py | Adds API tests verifying email call + invite_email_sent behavior. |
| services/platform/tests/customers/test_user_management_views.py | Adds staff-view tests verifying email call + warning-on-failure behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
services/platform/templates/customers/emails/welcome_email.html
Outdated
Show resolved
Hide resolved
…ic#145) New users created via the customer_users_create API and the staff customer_create_user view were left with unusable passwords and no email — permanently locked out. Call the existing _send_welcome_email_secure() to send a password-reset invite on creation. Email failure is non-blocking (user still created). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Ciprian Radulescu <craps2003@gmail.com>
42a30bd to
3c010c4
Compare
b3lz3but
added a commit
to b3lz3but/PRAHO
that referenced
this pull request
Mar 27, 2026
… request_ip audit logging - Fix welcome email templates: "3 days" → "2 hours" to match PASSWORD_RESET_TIMEOUT=7200s setting - Pass request_ip via get_safe_client_ip(request) to _send_welcome_email_secure for audit trail on both call sites - Update test assertions to verify request_ip is passed Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
Review feedback addressed (68129f2)
|
… request_ip audit logging - Fix welcome email templates: "3 days" → "2 hours" to match PASSWORD_RESET_TIMEOUT=7200s setting - Pass request_ip via get_safe_client_ip(request) to _send_welcome_email_secure for audit trail on both call sites - Update test assertions to verify request_ip is passed Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Ciprian Radulescu <craps2003@gmail.com>
68129f2 to
3658348
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
customer_users_create(API) andcustomer_create_user(staff view) now call the existing_send_welcome_email_secure()to send a password-reset inviteinvite_email_sent: falsecustomers/emails/welcome_email.html+.txt)Closes #145
Test plan
test_create_user_success— verifies invite email is called andinvite_email_sent: truein responsetest_create_user_invite_email_failure_still_succeeds— user created even if email failstest_create_user_sends_invite_email— staff view triggers emailtest_create_user_warns_on_email_failure— staff view shows warning on failure🤖 Generated with Claude Code