Skip to content

Commit

Permalink
Merge pull request #1812 from sebix/fix-1728
Browse files Browse the repository at this point in the history
Same messages for not found and access denied
  • Loading branch information
UlrichB22 authored Nov 27, 2024
2 parents 2320a83 + c9ecc24 commit 7ea02f3
Show file tree
Hide file tree
Showing 8 changed files with 1,792 additions and 1,574 deletions.
6 changes: 5 additions & 1 deletion src/moin/apps/frontend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,11 @@ def ajaxdestroy(item_name, req="destroy"):
if isinstance(item, NonExistent):
# we should not try to destroy a nonexistent item,
# user probably checked a subitem and checked do subitems
response["messages"].append(_("Item '{bad_name}' does not exist.").format(bad_name=item.name))
response["messages"].append(
_("Item '{bad_name}' does not exist or you do not have permission to access it.").format(
bad_name=item.name
)
)
continue
subitem_names = []
if req == "destroy":
Expand Down
2 changes: 1 addition & 1 deletion src/moin/templates/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h1> {{ _("Not Found") }}</h1>
<div class="error">
<p>
<strong>
{{ _("The item '{item_name}' does not exist.").format(item_name=item_name) }}
{{ _("The item '{item_name}' does not exist or you do not have permission to access it.").format(item_name=item_name) }}
</strong>
</p>
{% if path %}
Expand Down
4 changes: 2 additions & 2 deletions src/moin/templates/show_nonexistent.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends theme("layout.html") %}
{% block content %}
<h1>{{ _("Item not found") }}</h1>
<h1>{{ _("Item not found or access denied") }}</h1>
<p>
{{ _("Item '{name}' does not exist.").format(name=item_name) }}
{{ _("Item '{name}' does not exist or you do not have permission to access it.").format(name=item_name) }}
</p>
{% endblock %}
6 changes: 4 additions & 2 deletions src/moin/themes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ def render_template(template, **context):
def themed_error(e):
item_name = request.view_args.get("item_name", "")
if e.code == 403:
title = L_("Access Denied")
description = L_("You are not allowed to access this resource.")
title = L_("Item not found or access denied")
description = L_("Item '{name}' does not exist or you do not have permission to access it.").format(
name=item_name
)
if e.description.startswith(" "):
# leading blank indicates supplemental info, not standard werkzeug message
description += e.description
Expand Down
Loading

0 comments on commit 7ea02f3

Please sign in to comment.