From 644539bd6834f0c2934b21f644a1394c3fabc2d0 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 15 May 2020 12:44:25 +0300 Subject: [PATCH] Reset view: adjust reset view path and class. --- django_etesync/views.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/django_etesync/views.py b/django_etesync/views.py index 894f06d..dd110db 100644 --- a/django_etesync/views.py +++ b/django_etesync/views.py @@ -422,16 +422,22 @@ class AuthenticationViewSet(viewsets.ViewSet): return Response({}, status=status.HTTP_400_BAD_REQUEST) -class ResetViewSet(BaseViewSet): +class TestAuthenticationViewSet(viewsets.ViewSet): + authentication_classes = BaseViewSet.authentication_classes + permission_classes = BaseViewSet.permission_classes allowed_methods = ['POST'] - def post(self, request, *args, **kwargs): + def list(self, request): + return Response(status=status.HTTP_405_METHOD_NOT_ALLOWED) + + @action_decorator(detail=False, methods=['POST']) + def reset(self, request, *args, **kwargs): # Only run when in DEBUG mode! It's only used for tests if not settings.DEBUG: return HttpResponseBadRequest("Only allowed in debug mode.") # Only allow local users, for extra safety - if not getattr(request.user, User.USERNAME_FIELD).endswith('@localhost'): + if not getattr(request.user, User.EMAIL_FIELD).endswith('@localhost'): return HttpResponseBadRequest("Endpoint not allowed for user.") # Delete all of the journal data for this user for a clear test env @@ -440,6 +446,3 @@ class ResetViewSet(BaseViewSet): # FIXME: also delete chunk files!!! return HttpResponse() - - -reset = ResetViewSet.as_view({'post': 'post'})