-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(accounts): Allow disabling email sending to unknown addresses
Add a setting to the accounts app which disables sending emails to addresses which do not have an account. For many sites this behaviour will be undesirable since it sends potentially unsolicited email to someone who has not shared it with us.
- Loading branch information
Showing
5 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,28 @@ def test_password_forgotten_no_username_hint(self): | |
body = mail.outbox[0].body | ||
assert user.username not in body | ||
|
||
@override_settings( | ||
ACCOUNT_PREVENT_ENUMERATION=True, | ||
) | ||
def test_reset_password_unknown_account(self): | ||
self.client.post( | ||
reverse("account_reset_password"), | ||
data={"email": "[email protected]"}, | ||
) | ||
self.assertEqual(len(mail.outbox), 1) | ||
self.assertEqual(mail.outbox[0].to, ["[email protected]"]) | ||
|
||
@override_settings( | ||
ACCOUNT_PREVENT_ENUMERATION=True, | ||
ACCOUNT_SEND_TO_UNKNOWN_EMAILS=False, | ||
) | ||
def test_reset_password_unknown_account_disabled(self): | ||
self.client.post( | ||
reverse("account_reset_password"), | ||
data={"email": "[email protected]"}, | ||
) | ||
self.assertEqual(len(mail.outbox), 0) | ||
|
||
def _request_new_password(self): | ||
user = get_user_model().objects.create( | ||
username="john", email="[email protected]", is_active=True | ||
|
This file contains 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