Skip to content
Advertisement

email authentification doesn’t work using django-allauth

I installed django-allauth and set it up to use it for the internet registration and authentication backend in order to have an email confirmation at registration and sign up the users using their email instead of their username.

What is happening is that the registration works perfectly, the authentication using the email doesn’t work whereas it’s working with the username. I got the following error:

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

Here my current configuration:

  • Django-allauth: 0.35.0
  • Django: 1.11
  • Python: 3.6.4
  • mysql: 15.1
JavaScript
JavaScript

I hope I gave all the useful information. I wonder if I missed a configuration issue or if there is a bug somewhere. If you need more information, please let me know, I will gladly provide my help on that matter.

Advertisement

Answer

After some thinking and research, I found a workaround by writing my own adapter as described in the documentation. It consists of rewriting the method save_user().

In order to proceed, you need first to tell your app where is the new adapter by editing the settings.py and adding the following line:

JavaScript

Then create the adapter file such as yourproject/yourapp.file.py, in my case I called the file.py adapter.py and add the following code:

JavaScript

Basically, it’s really close to the actual method except I save the email as such as the username in the django system. You will need as well to edit the login.html template if you want to avoid confusion with your user and force the username field to display email.

To avoid any issues related to a malformed email address, you can then add a validator as described in the documentation.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement