-
-
Notifications
You must be signed in to change notification settings - Fork 143
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
Allow decoration of functions beyond the admin login #86
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you. Only a couple of minor comments/questions
@@ -724,6 +729,81 @@ def test_disable_username_lockout(self): | |||
data_out = utils.get_blocked_usernames() | |||
self.assertEqual(data_out, []) | |||
|
|||
@patch('defender.config.BEHIND_REVERSE_PROXY', True) | |||
@patch('defender.config.FAILURE_LIMIT', 3) | |||
def test_login_blocked_for_non_standard_login_views_without_msg(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add docstrings to the test methods explaining what each test does? Not all tests have them now, and I have been meaning to fix that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, no problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx
LoginView.dispatch = watch_login_method(LoginView.dispatch) | ||
except ImportError: # Django < 1.11 | ||
auth_views.login = watch_login(auth_views.login) | ||
auth_views.login = watch_login()(auth_views.login) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that correct? I'm no expert when it comes to decorators so might be correct, it just looks weird with watch_login()(auth_views.login)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks weird but it's correct. The old decorator couldn't accept arguments and had a deep of 2. I had to add one more level in order to accept arguments so the first thing the new decorator expects now are the arguments (or the defaults) while here a function was passed in first instance. Does it make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thank you.
It looks like coverage dropped a little, and a few more quantified code minor issues were found. Other than that, pretty good, thanks for the PR. |
I just merged another PR, it looks like there is a conflict. |
@kencochrane please review again, I added the docstrings but also 3 more commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, looks good. Thank you!
PR looks good, I'll leave it open for a bit in case anyone else wants to review. If no one else comments, I'll merge. |
👍 |
Can I use this yet? |
@kencochrane as discussed in #85