Skip to content

Commit

Permalink
Make sure sign-out doesn't 404. Code tidying.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmenezes0 committed Aug 13, 2024
1 parent 9531c8e commit e30b0a9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions consultation_analyser/consultations/views/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ def destroy(request: HttpRequest):

@method_decorator(login_not_required, name="dispatch")
class MagicLinkView(magic_link.views.MagicLinkView):
# Explicitly declared class so can use decorator.
pass
8 changes: 3 additions & 5 deletions consultation_analyser/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ def __init__(self, get_response):
def __call__(self, request):
response = self.get_response(request)
if request.path.startswith("/support/"):
if not request.user.is_staff:
# Must already be logged in from login required middleware.
# Sign-out is excepted as we don't want to 404 on sign-out.
if (not request.user.is_staff) and (not request.path.startswith("/support/sign-out/")):
raise Http404
# if not request.user.is_authenticated:
# return HttpResponseNotFound()
# elif not request.user.is_staff:
# return HttpResponseNotFound()
return response


Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_logging_in_to_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def test_logging_in_to_support(client):
# given I am a logged in admin user
user = UserFactory(
email="[email protected]",
password="admin", # pragma: allowlist secret
# password="admin", # pragma: allowlist secret
is_staff=True,
)
client.force_login(user)
Expand Down

0 comments on commit e30b0a9

Please sign in to comment.