-
Notifications
You must be signed in to change notification settings - Fork 529
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
Feature: Added an account disabled page #3391
base: main
Are you sure you want to change the base?
Conversation
Hi @RafaelJohn9, is this ready for review? Could you please rebase it? Do you mind if I do it? |
uhmm yea sure @mathjazz , you can take on the issue 🤝 , sorry for the delay |
hey @mathjazz, on second thoughts, lemme complete this 🤝 |
Signed-off-by: RafaelJohn9 <rafaeljohb@gmail.com>
0ebd442
to
d76b3f9
Compare
…to see if the reason its not being activated arrives from its possition in the middlewares\n Signed-off-by: RafaelJohn9 <rafaeljohb@gmail.com>
Signed-off-by: RafaelJohn9 <rafaeljohb@gmail.com>
hey @mathjazz , well I've configured everything correctly, issue arises in the |
Looking for a way to by pass this 🤝 |
Signed-off-by: RafaelJohn9 <rafaeljohb@gmail.com>
oops, well |
Signed-off-by: RafaelJohn9 <rafaeljohb@gmail.com>
Signed-off-by: RafaelJohn9 <rafaeljohb@gmail.com>
Signed-off-by: RafaelJohn9 <rafaeljohb@gmail.com>
Signed-off-by: RafaelJohn9 <rafaeljohb@gmail.com>
Signed-off-by: RafaelJohn9 <rafaeljohb@gmail.com>
Signed-off-by: RafaelJohn9 <rafaeljohb@gmail.com>
Signed-off-by: RafaelJohn9 <rafaeljohb@gmail.com>
Signed-off-by: RafaelJohn9 <rafaeljohb@gmail.com>
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.
Thanks for the patch! Left some comments inline.
pontoon/base/middleware.py
Outdated
# For non-authenticated users, check the session manually | ||
user_id = request.session.get("_auth_user_id") | ||
if user_id: | ||
try: | ||
user = User.objects.get(pk=user_id) | ||
if not user.is_active: | ||
return render( | ||
request, | ||
"account_disabled.html", | ||
{"DEFAULT_FROM_EMAIL": settings.DEFAULT_FROM_EMAIL}, | ||
status=403, | ||
) | ||
except User.DoesNotExist: | ||
pass # If the user ID is invalid, ignore it |
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.
What exactly does this code do? If the user is not authenticated, we shouldn't do anything.
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.
@mathjazz , I was having trouble running the code without this patch, mainly when the user is not active and wishes to login, it does not pass through the AuthMiddleware
,
did some digging and found that one of the requirements for a user to be authenticated is that the user must be active
I tried checking if both is_active
and is_authenticated
is false, however, this sort of thing affects AnonymousUser
's meaning they can't browse any pages if you aren't authenticated.
So I updated the patch to have two parts just in case:
- User
is_authenticated
and not active - User is not active but is an existing user in the database
the path highlighted presents the second part of the patch,
Signed-off-by: RafaelJohn9 <rafaeljohb@gmail.com>
The back-end test failure should be unrelated. You will need to rebase once the test is fixed. |
okay 👍 |
this PR addresses issue #3153