Skip to content

added feature to send email once the user is blocked based on username#242

Open
saurav-codes wants to merge 1 commit intojazzband:masterfrom
saurav-codes:master
Open

added feature to send email once the user is blocked based on username#242
saurav-codes wants to merge 1 commit intojazzband:masterfrom
saurav-codes:master

Conversation

@saurav-codes
Copy link

Implementation Details

The implementation checks for a new setting, DEFENDER_EMAIL_USER_ON_ACCOUNT_LOCKED, to determine if an email should be sent when an account is locked. by default it's False.

An email template defender/lockout_email.html is provided, which can be overridden by setting DEFENDER_LOCKOUT_EMAIL_TEMPLATE_PATH in the project's settings. The email is sent using Django's built-in send_mail function, assuming that the email backend configured for the project.

@codecov
Copy link

codecov bot commented Feb 26, 2024

Codecov Report

Attention: Patch coverage is 52.94118% with 8 lines in your changes missing coverage. Please review.

Project coverage is 91.03%. Comparing base (cc35032) to head (f39e27f).

Files with missing lines Patch % Lines
defender/utils.py 42.85% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #242      +/-   ##
==========================================
- Coverage   92.58%   91.03%   -1.55%     
==========================================
  Files          13       13              
  Lines         418      435      +17     
==========================================
+ Hits          387      396       +9     
- Misses         31       39       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kencochrane
Copy link
Collaborator

@saurav-codes it looks like some of the tests failed, it might require a change to the tox settings. maybe something changed recently.

@kencochrane
Copy link
Collaborator

@saurav-codes The change looks reasonable; if you can get the tests to pass and update the documentation, it should be good to merge. Thanks

@wind-shift
Copy link
Contributor

Just out of curiosity, wouldn’t it be slightly better to implement this based on django signals ? This would allow to plug-in other notification sources than email.

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.

3 participants