Skip to content
Snippets Groups Projects
Commit ae5ffbbb authored by robinwilliam.hundt's avatar robinwilliam.hundt
Browse files

Added /jwt-time-delta/

This endpoint returns the time delta of the JWT Tokens as specified in the settings file #22
parent af146891
No related branches found
No related tags found
1 merge request!23Resolve "Logout of tutors after inactivity"
...@@ -18,6 +18,7 @@ regular_views_urlpatterns = [ ...@@ -18,6 +18,7 @@ regular_views_urlpatterns = [
url(r'student-page', views.StudentSelfApiView.as_view(), name='student-page'), url(r'student-page', views.StudentSelfApiView.as_view(), name='student-page'),
url(r'user-role', views.get_user_role, name='user-role'), url(r'user-role', views.get_user_role, name='user-role'),
url(r'exam-module', views.get_exam_module, name='exam-module'), url(r'exam-module', views.get_exam_module, name='exam-module'),
url(r'jwt-time-delta', views.get_jwt_expiration_delta, name='jwt-time-delta')
] ]
urlpatterns = [ urlpatterns = [
......
""" All API views that are used to retrieve data from the database. They """ All API views that are used to retrieve data from the database. They
can be categorized by the permissions they require. All views require a can be categorized by the permissions they require. All views require a
user to be authenticated and most are only accessible by one user group """ user to be authenticated and most are only accessible by one user group """
from django.conf import settings
from rest_framework import mixins, viewsets, generics from rest_framework import mixins, viewsets, generics
from rest_framework.decorators import api_view from rest_framework.decorators import api_view
from rest_framework.response import Response from rest_framework.response import Response
...@@ -12,6 +13,11 @@ from core.serializers import (ExamSerializer, StudentSerializer, ...@@ -12,6 +13,11 @@ from core.serializers import (ExamSerializer, StudentSerializer,
SubmissionTypeSerializer, TutorSerializer) SubmissionTypeSerializer, TutorSerializer)
@api_view()
def get_jwt_expiration_delta(request):
return Response({'timeDelta': settings.JWT_AUTH['JWT_EXPIRATION_DELTA']})
@api_view() @api_view()
def get_user_role(request): def get_user_role(request):
return Response({'role': type(request.user.get_associated_user()).__name__}) return Response({'role': type(request.user.get_associated_user()).__name__})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment