-
-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
django-defender not working on my custom login view #173
Comments
If you are logging access attempts are you seeing any entries in the database for you login attempts? |
No I am not saving the logs in the database, I believe the issue may be my EDIT I'd like to also note that when I use
|
What version of defender, Python, and django are you using? Maybe use the decorator on the urls.py like shown here? |
My python version is 3.8, Django version is 3.0, and my defender is 0.8.0. I have already tried wrapping it around in my urls.py I still get the same error |
There might be an exception getting thrown from the decorator that is causing this error, can you post the full stack trace? |
THIS METHOD HAS FLAWS I was able to fix this issue. The problem was that inside my So now my login view is:
I think this issue can be marked as closed if my method seems to work correctly |
I'm glad you have it working, feel free to close this issue unless there is something else we can help you with. |
There is a slight issue with this approach and it is that that when we do not redirect after incorrect credentials, the POST form fields are not cleared from the browser and can cause the duplicate submission of the form. Django redirects with status code 302 on the wrong login, however, here: django-defender/defender/decorators.py Lines 29 to 34 in a1d526f
This will cause watch_login() to always fail since we are returning 302 for both successful and unsuccessful login attempts. Now I do not know what would be the best status code for this case. I am currently using 303, but I don't think it's the best option here. |
OK, have you looked at how the official Django login view handles it, maybe you can copy what they did to get yours working correctly. |
I have taken a look at Django's LoginView and it seems that after failed login, Django renders the form with the error messages which means that the previous POST parameters are still saved on the browser. As far as my understanding this seems to be an odd issue with References: https://docs.djangoproject.com/en/3.1/topics/auth/default/#django.contrib.auth.views.LoginView |
Hello, I am trying to add
watch_login()
decorator to y custom login view however, my user is still able to login after passing the lockout limit which I currently set to 3.My current settings is:
And my custom login is:
And for my cache I am using Redis so currently, I have:
I do not see any errors except that the django-defender is doing nothing I was wondering how I could fix this issue.
The text was updated successfully, but these errors were encountered: