0

have one question, how to check email ending via django social auth? For example I want that to my site could connect peoples who have email with @example.com ending.

jhonkola
  • 3,385
  • 1
  • 17
  • 32
BenG
  • 401
  • 4
  • 7
  • 15

2 Answers2

2

Add a pipeline entry that does the check, something like this should do the trick:

def check_email(details, *args, **kwargs):
    email = details['email']
    if not email.endswith('@example.com'):
        return HttpResponseRedirect('/invalid-email')

Put that before the create_user entry and. Take into account that some providers don't return the email (like Twitter).

omab
  • 3,721
  • 19
  • 23
1

If you are only using the google backend you can use the GOOGLE_WHITE_LISTED_DOMAINS setting.

Set it to a list of domains to restrict users to.

GOOGLE_WHITE_LISTED_DOMAINS = ['somedomain.com', 'anotherdomain.com']

More info here:

http://django-social-auth.readthedocs.org/en/latest/backends/google.html

emispowder
  • 1,787
  • 19
  • 21