Skip to content

Commit

Permalink
fix(socialaccount): SOCIALACCOUNT_ONLY vs EMAIL_VERIFICATION
Browse files Browse the repository at this point in the history
  • Loading branch information
pennersr authored and pennersr committed Jan 24, 2025
1 parent 5507bf3 commit ad5a248
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
10 changes: 9 additions & 1 deletion allauth/socialaccount/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ def EMAIL_VERIFICATION(self):
See email verification method. When `None`, the default
`allauth.account` logic kicks in.
"""
return self._setting("EMAIL_VERIFICATION", None)
from allauth import app_settings as allauth_settings
from allauth.account import app_settings as account_settings

dflt = (
account_settings.EmailVerificationMethod.NONE
if allauth_settings.SOCIALACCOUNT_ONLY
else None
)
return self._setting("EMAIL_VERIFICATION", dflt)

@property
def EMAIL_AUTHENTICATION(self):
Expand Down
1 change: 1 addition & 0 deletions allauth/socialaccount/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class SocialAccountConfig(AppConfig):
default_auto_field = app_settings.DEFAULT_AUTO_FIELD or "django.db.models.AutoField"

def ready(self):
from allauth.socialaccount import checks # noqa
from allauth.socialaccount.providers import registry

registry.load()
21 changes: 21 additions & 0 deletions allauth/socialaccount/checks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.core.checks import Critical, register


@register()
def settings_check(app_configs, **kwargs):
from allauth import app_settings as allauth_settings
from allauth.account import app_settings as account_settings
from allauth.socialaccount import app_settings

ret = []
if allauth_settings.SOCIALACCOUNT_ONLY:
if (
app_settings.EMAIL_VERIFICATION
!= account_settings.EmailVerificationMethod.NONE
):
ret.append(
Critical(
msg="SOCIALACCOUNT_ONLY requires SOCIALACCOUNT_EMAIL_VERIFICATION = 'none'"
)
)
return ret

0 comments on commit ad5a248

Please sign in to comment.