-
Notifications
You must be signed in to change notification settings - Fork 530
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 <[email protected]>
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 <[email protected]>
Signed-off-by: RafaelJohn9 <[email protected]>
hey @mathjazz , well I've configured everything correctly, issue arises in the |
Looking for a way to by pass this 🤝 |
Signed-off-by: RafaelJohn9 <[email protected]>
oops, well |
Signed-off-by: RafaelJohn9 <[email protected]>
Signed-off-by: RafaelJohn9 <[email protected]>
Signed-off-by: RafaelJohn9 <[email protected]>
Signed-off-by: RafaelJohn9 <[email protected]>
Signed-off-by: RafaelJohn9 <[email protected]>
Signed-off-by: RafaelJohn9 <[email protected]>
Signed-off-by: RafaelJohn9 <[email protected]>
Signed-off-by: RafaelJohn9 <[email protected]>
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.
"default": { | ||
"BACKEND": "django_bmemcached.memcached.BMemcached", | ||
"OPTIONS": {}, | ||
} |
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.
Nit: Please restore this change. :)
map( | ||
int, | ||
os.environ.get("BADGES_PROMOTION_THRESHOLDS", "1, 2, 5").split(","), | ||
) |
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.
Nit: Please restore this change. :)
{% block title %}Account Disabled{% endblock %} | ||
{% block description %} | ||
Your account has been disabled. If you believe this is a mistake or need further assistance, please contact us at {{ DEFAULT_FROM_EMAIL }}. | ||
{% endblock %} |
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.
Please add the new line at the end of the file.
|
||
{% block title %}Account Disabled{% endblock %} | ||
{% block description %} | ||
Your account has been disabled. If you believe this is a mistake or need further assistance, please contact us at {{ DEFAULT_FROM_EMAIL }}. |
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.
Please make the email address a mailto:
hyperlink.
return render( | ||
request, | ||
"account_disabled.html", | ||
{"DEFAULT_FROM_EMAIL": settings.DEFAULT_FROM_EMAIL}, |
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 we remove this line? I didn't check, but the context_processor
should pass settings
to all templates:
https://github.com/mozilla/pontoon/blob/08710a279ab2f2c52b7f1a1a1035b6778c5f7f95/pontoon/base/context_processors.py
We'd need to change DEFAULT_FROM_EMAIL
to settings.DEFAULT_FROM_EMAIL
in account_disabled.html
though.
# 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 authenticate, 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,
this PR addresses issue #3153