Add /ping/ API route to check if user's token is valid

This commit is contained in:
Tanner Collin 2020-02-04 08:31:24 +00:00
parent ee520b8c3f
commit 26845a5921
2 changed files with 9 additions and 0 deletions

View File

@ -250,6 +250,14 @@ class UserView(views.APIView):
return Response(serializer.data) return Response(serializer.data)
class PingView(views.APIView):
permission_classes = [AllowMetadata | IsAuthenticated]
def post(self, request):
return Response(200)
class DoorViewSet(viewsets.ViewSet, List): class DoorViewSet(viewsets.ViewSet, List):
def list(self, request): def list(self, request):
cards = models.Card.objects.filter(active_status='card_active') cards = models.Card.objects.filter(active_status='card_active')

View File

@ -29,5 +29,6 @@ urlpatterns = [
url(r'^registration/', views.RegistrationView.as_view(), name='rest_name_register'), url(r'^registration/', views.RegistrationView.as_view(), name='rest_name_register'),
url(r'^password/change/', views.PasswordChangeView.as_view(), name='rest_password_change'), url(r'^password/change/', views.PasswordChangeView.as_view(), name='rest_password_change'),
url(r'^user/', views.UserView.as_view(), name='user'), url(r'^user/', views.UserView.as_view(), name='user'),
url(r'^ping/', views.PingView.as_view(), name='ping'),
url(IPN_ROUTE, views.IpnView.as_view(), name='ipn'), url(IPN_ROUTE, views.IpnView.as_view(), name='ipn'),
] ]