diff --git a/app/views.py b/app/views.py index 048e133..dfeef35 100644 --- a/app/views.py +++ b/app/views.py @@ -1,4 +1,6 @@ from requests import get +from cryptography.fernet import Fernet +from django.contrib.sessions.backends.db import SessionStore from django.http import HttpResponse, JsonResponse from django.shortcuts import render import json @@ -48,6 +50,8 @@ def login(request, *args, **kwargs): else: request.session['is_logged'] = True data_response = {'success': True, 'data': sender_return} + key = Fernet.generate_key() + request.session[request.session.session_key] = key.decode('utf-8') return JsonResponse(data_response) def grades(request, *args, **kwargs): @@ -57,6 +61,7 @@ def grades(request, *args, **kwargs): register_r = data['data']['register_r'] oun = data['data']['oun'] s = data['data']['s'] + print(request.session[request.session.session_key].encode('utf-8')) grades = get_grades(register_id, register_r, oun, s) return JsonResponse(grades) else: diff --git a/requirements.txt b/requirements.txt index ae20cab..e1abe1e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ bs4==0.0.1 Django==3.1.3 python-dotenv==0.15.0 requests==2.24.0 +cryptography==3.2.1 \ No newline at end of file diff --git a/wulkanowy/settings.py b/wulkanowy/settings.py index fd6326c..2476657 100644 --- a/wulkanowy/settings.py +++ b/wulkanowy/settings.py @@ -58,6 +58,8 @@ MIDDLEWARE = [ 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] +SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db' + SESSION_EXPIRE_AT_BROWSER_CLOSE = True SESSION_COOKIE_AGE = 1200