valohai / django-allauth-2fa

Two-factor authentication for Django Allauth
Other
210 stars 50 forks source link

Not compatible with function-based login view #143

Closed rrlapointe closed 2 years ago

rrlapointe commented 2 years ago

This project is incompatible with the case where the login view is a function-based view.

If an app overrides the /accounts/login/ login view with a function-based view (as opposed to a class-based view), the following line throws AttributeError 'function' object has no attribute 'view_class' when a user tries to log in: https://github.com/valohai/django-allauth-2fa/blob/cb71b7373598e74d035bcf19ef472db6c0b08df3/allauth_2fa/adapter.py#L25

Documenting this incompatibility with this issue so that others spend less time debugging that error.

akx commented 2 years ago

Regressed in 97a3fc9ce7f038a99bceedc35485ba79ced55a03 – should just have a fallback for the case when the view is not a class.

pbadeer commented 1 year ago

This fix is critical for a project I'm involved in, where the original issue is currently breaking our ability to allow social logins with django-allauth. Could we get this put into a release soon? Would love to pull it in!

rrlapointe commented 1 year ago

In my case I worked around the issue by using a class-based login view subclassing allauth.account.views.LoginView instead of a function-based login view.

pbadeer commented 1 year ago

For context, this has been fixed already, it works for me on the main branch, but it has not been put into a release. The last release was in July of 2022