Skip to content

Send invitation emails via async task and use crypto-safe secrets - #254

Merged
norkans7 merged 2 commits into
mainfrom
invitation-fixes
Jul 27, 2026
Merged

Send invitation emails via async task and use crypto-safe secrets#254
norkans7 merged 2 commits into
mainfrom
invitation-fixes

Conversation

@norkans7

Copy link
Copy Markdown
Contributor

Invitation.send_invitation() invoked the celery task function directly, running the email send synchronously inside the web request — an SMTP outage could 500 the accounts management view partway through updating org membership. Invitation secrets were also generated with the non-cryptographic random module despite gating account creation.

The email task is now dispatched with .delay() inside transaction.on_commit (so a worker can't race the uncommitted row), the task no-ops gracefully if the invitation has been deleted, and secrets use secrets.choice. Test settings enable celery eager mode so the email assertions exercise the async path.

norkans7 added 2 commits July 27, 2026 13:36
Dispatch the invitation email celery task with .delay() after the
transaction commits instead of running it synchronously in the request,
make the task a no-op if the invitation no longer exists, and generate
invitation secrets with the secrets module instead of random.
…ypto-safe random for secrets and check uniqueness with exists()
@norkans7
norkans7 merged commit 9ef6963 into main Jul 27, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant