Commit 8ca2286a authored by Michal Čihař's avatar Michal Čihař

Fallback to anonymous user for not authenticated requests

Fixes #882
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 8fbcd5d6
......@@ -21,7 +21,7 @@
Permissions abstract layer for Weblate.
"""
from weblate import appsettings
from django.contrib.auth.models import Group
from django.contrib.auth.models import Group, User
def check_owner(user, project, permission):
......@@ -55,7 +55,11 @@ def cache_permission(func):
"""
def wrapper(user, target_object):
if target_object is None or user is None:
if user is None:
user = User.objects.get(
username=appsettings.ANONYMOUS_USER_NAME,
)
if target_object is None:
return func(user, target_object)
key = (func.__name__, user.id)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment