Compare commits

..

1 Commits

Author SHA1 Message Date
Yann Weber 49c5174ac4 manager: make agenda's groups foldable (#85616)
gitea/chrono/pipeline/head This commit looks good Details
2024-04-03 10:50:39 +02:00
2 changed files with 6 additions and 3 deletions

View File

@ -31,11 +31,9 @@ def save_preference(request):
Given a JSON with a single boolean value identified by a str, save the
key <-> value association in UserPreference
'''
if not request.user:
if not request.user or not request.user.is_authenticated:
raise PermissionDenied()
user_pref = models.UserPreferences.objects.get_or_create(user=request.user)[0]
if not user_pref:
raise PermissionDenied()
if len(request.body) > 1000:
return HttpResponse(_('Payload is too large').encode(), status=400)

View File

@ -78,3 +78,8 @@ def test_user_preferences_api_large_payload(app, admin_user):
url = reverse('api-user-preferences')
app.post(url, params='a' * 1024, status=400)
app.post_json(url, params={'b' * 1024: True}, status=400)
def test_user_preferences_api_unauthorized(app):
url = reverse('api-user-preferences')
app.post(url, params={'toto': True}, status=403)