Skip to content

Commit

Permalink
skip User.EMAIL_FIELD check if not invalidating on email change
Browse files Browse the repository at this point in the history
  • Loading branch information
megagator authored and aaugustin committed Aug 9, 2023
1 parent b08beec commit eb312b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions src/sesame/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,15 @@ def check():
)

global INVALIDATE_ON_EMAIL_CHANGE
User = get_user_model()
try:
User._meta.get_field(User.get_email_field_name())
except FieldDoesNotExist:
raise ImproperlyConfigured(
"invalid configuration: set User.EMAIL_FIELD correctly "
"or set SESAME_INVALIDATE_ON_EMAIL_CHANGE to False"
)
if INVALIDATE_ON_EMAIL_CHANGE:
User = get_user_model()
try:
User._meta.get_field(User.get_email_field_name())
except FieldDoesNotExist:
raise ImproperlyConfigured(
"invalid configuration: set User.EMAIL_FIELD correctly "
"or set SESAME_INVALIDATE_ON_EMAIL_CHANGE to False"
)


check()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_insecure_configuration(self):
)

@override_settings(
SESAME_INVALIDATE_ON_EMAIL_CHANGE=False,
SESAME_INVALIDATE_ON_EMAIL_CHANGE=True,
AUTH_USER_MODEL="tests.StrUser",
)
def test_invalid_configuration(self):
Expand Down

0 comments on commit eb312b1

Please sign in to comment.