-
Notifications
You must be signed in to change notification settings - Fork 37
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
Raise PermissionDenied for inactive user accounts #826
Conversation
Codecov Report
@@ Coverage Diff @@
## master #826 +/- ##
=========================================
+ Coverage 90.87% 90.9% +0.03%
=========================================
Files 39 39
Lines 1742 1748 +6
=========================================
+ Hits 1583 1589 +6
Misses 159 159
Continue to review full report at Codecov.
|
tock/tock/remote_user_auth.py
Outdated
@@ -5,11 +5,13 @@ | |||
from django.core.exceptions import ValidationError | |||
from django.conf import settings | |||
from django.contrib.auth.models import User | |||
from django.core.exceptions import PermissionDenied |
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.
Let's combine this with the ValidationError imported on L5 (and while we're at it, we can better match up our imports with best conventions)
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.
Whoops, missed that one thanks!
Deny access by and provide a help message to users with inactive accounts.
8c222c3
to
4fd483c
Compare
|
||
def user_can_authenticate(self, user): | ||
if not user.is_active: | ||
raise PermissionDenied(ACCOUNT_INACTIVE_MSG) |
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.
This is an interesting way of handling this. In my head, I think I saw either redirecting to a simple templateView or maybe leveraging the messages framework, but I think I like piggybacking on the 403.
Description
For #825, deny access by and provide a help message to users with inactive accounts.
Additional information
Prevents inactive users from completing authentication w/ tock backend.