Skip to content

Commit

Permalink
fix(permissions): raise error if user is missing in context
Browse files Browse the repository at this point in the history
Silently ignoring this makes it easy to miss user in some inclusion
template tags and the permission check then silently returns false.
  • Loading branch information
nijel committed Oct 1, 2024
1 parent 5a85984 commit 453fca6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions weblate/auth/templatetags/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
def perm(context, permission, obj=None):
try:
user = context["user"]
except KeyError:
return False
except KeyError as error:
raise ValueError(
"Missing user in context, could not perform permission check"
) from error
return user.has_perm(permission, obj)

0 comments on commit 453fca6

Please sign in to comment.