I've got a custom user model like so—
class User(AbstractBaseUser):
email = models.EmailField(unique=True)
USERNAME_FIELD = 'email'
I've added the appropriate social-auth settings—
AUTHENTICATION_BACKENDS = (
'social.backends.persona.PersonaAuth',
)
AUTH_USER_MODEL = 'accounts.User'
SOCIAL_AUTH_USER_MODEL = 'accounts.User'
When trying to log in, a user with the email beau@<domain> gets created, however the email in the database is set to something like beau1234567890. That user doesn't authenticate (ie, request.user is still AnonymousUser).
If I nuke the AUTH_USER_MODEL and SOCIAL_AUTH_USER_MODEL, I can log in fine.
I'm speculating the issue is because the user model has a field called email, but it's also the USERNAME_FIELD. Hence, trying to create a user, social-auth creates a unique username, and overrides the email with that, assuming we'd have separate email and username fields—which is the case when using the default, django.contrib.auth.models.User model.
Any ideas on how to fix this?
I've got a custom user model like so—
I've added the appropriate social-auth settings—
When trying to log in, a user with the email
beau@<domain>gets created, however the email in the database is set to something likebeau1234567890. That user doesn't authenticate (ie,request.useris stillAnonymousUser).If I nuke the
AUTH_USER_MODELandSOCIAL_AUTH_USER_MODEL, I can log in fine.I'm speculating the issue is because the user model has a field called
email, but it's also theUSERNAME_FIELD. Hence, trying to create a user, social-auth creates a unique username, and overrides the email with that, assuming we'd have separateemailandusernamefields—which is the case when using the default,django.contrib.auth.models.Usermodel.Any ideas on how to fix this?