Skip to content

Commit

Permalink
Merge pull request #745 from dbaxa/fix_the_GOOGLE_WHITE_LISTED_EMAILS…
Browse files Browse the repository at this point in the history
…_validation_code

Fix the google white listed emails validation code
  • Loading branch information
omab committed Aug 20, 2013
2 parents 9bb9bbf + eefbbc0 commit e37dbac
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions social_auth/backends/google.py
Expand Up @@ -252,10 +252,13 @@ def validate_whitelists(backend, email):
"""
emails = setting('GOOGLE_WHITE_LISTED_EMAILS', [])
domains = setting('GOOGLE_WHITE_LISTED_DOMAINS', [])
if emails and email in emails:
return # you're good
if domains and email.split('@', 1)[1] not in domains:
raise AuthFailed(backend, 'Domain not allowed')
if not emails and not domains:
return True
if email in set(emails):
return True # you're good
if email.split('@', 1)[1] in set(domains):
return True
raise AuthFailed(backend, 'User not allowed')


# Backend definition
Expand Down

0 comments on commit e37dbac

Please sign in to comment.