2

I was looking around the documentation for django-social-auth but I can't seem to find a setting that will enforce unique emails for user accounts.

Is there any way of accomplishing this?

AlexBrand
  • 11,971
  • 20
  • 87
  • 132
  • what do you mean ? 2 accounts with 1 email ? or an account with several emails ? – SpiXel Aug 23 '12 at 22:09
  • I created an account through the regular django-auth system, then used social-auth with facebook and another account was created, so two user accounts have email example@ex.com – AlexBrand Aug 23 '12 at 22:10
  • possible duplicate of [How to have unique emails with python social auth](http://stackoverflow.com/questions/19273904/how-to-have-unique-emails-with-python-social-auth) – neves Oct 10 '13 at 20:17

2 Answers2

0

I believe the answer can be found in this other question.

It says to put another step in edit the SOCIAL_AUTH_PIPELINE. I believe this this is a simpler solution.

Community
  • 1
  • 1
neves
  • 33,186
  • 27
  • 159
  • 192
-1

The easiest thing to do is subclass the UserManager class, and overwrite its create_user method to check that there isn't a User instance with that email address in the database (django-social-auth uses create_user to...create users on registration). A bit more on how to set this up is on the Configuration page of the django-social-auth docs. You'll then need to subclass User as well, so that you can associate the custom manager with it. More on model Managers from the Django docs.

Jeff Tratner
  • 16,270
  • 4
  • 47
  • 67