Warm tip: This article is reproduced from serverfault.com, please click

django allauth email login

发布于 2015-01-15 15:46:06

If I change my allauth authentication method to email in django settings I always get the following error:

The e-mail address and/or password you specified are not correct.

Even though the email matches the one in the database.

I tried this in a clean django project using the following settings:

ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "optional"

I set email verification to optional to eliminate a source for the error but the issue remains regardless of whether or not I confirm the email address.

Questioner
matteok
Viewed
11
Abhishek 2015-03-11 04:44:43

I faced the same problem. My arse was on fire because of deadline, hence I figured out a way around. Thought of sharing. I took the user instance by using the filter and then populated the POST by copying the data from original request.

self.user = User.objects.get(email=request.POST['email'])

then

self.request.POST = self.request.DATA.copy()

I was using REST Request objects, hence the DATA. You can create another mutable POST object using some method.Note that original POST is immutable and you can't add anything into it. And then finally

self.request.POST['login'] = self.user.username

and then calling the form_valid of LoginView. Hope this helps.