-
-
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
37 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 |
---|---|---|
|
@@ -6,12 +6,36 @@ | |
from django.test.utils import override_settings | ||
from django.urls import reverse | ||
|
||
import pytest | ||
|
||
from allauth.account import app_settings | ||
from allauth.account.forms import ResetPasswordForm | ||
from allauth.account.models import EmailAddress | ||
from allauth.tests import TestCase | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_reset_password_unknown_account(client, settings): | ||
settings.ACCOUNT_PREVENT_ENUMERATION = True | ||
client.post( | ||
reverse("account_reset_password"), | ||
data={"email": "[email protected]"}, | ||
) | ||
assert len(mail.outbox) == 1 | ||
assert mail.outbox[0].to == ["[email protected]"] | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_reset_password_unknown_account_disabled(client, settings): | ||
settings.ACCOUNT_PREVENT_ENUMERATION = True | ||
settings.ACCOUNT_EMAIL_UNKNOWN_ACCOUNTS = False | ||
client.post( | ||
reverse("account_reset_password"), | ||
data={"email": "[email protected]"}, | ||
) | ||
assert len(mail.outbox) == 0 | ||
|
||
|
||
@override_settings( | ||
ACCOUNT_PREVENT_ENUMERATION=False, | ||
ACCOUNT_DEFAULT_HTTP_PROTOCOL="https", | ||
|
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