-
Dan Braghis authoredDan Braghis authored
utils.py 473 B
from django.conf import settings
def can_use_oauth_check(user):
"""
Checks that the user belongs to the whitelisted domains.
Anonymous or non-whitelisted email domains cannot log in
or associate OAuth accounts
"""
try:
domain = user.email.split('@')[-1]
return domain in settings.SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS
except AttributeError:
# Anonymous user or setting not defined
pass
return False