Generating and saveing key
This commit is contained in:
parent
c654711b4a
commit
8d7fa9eeab
3 changed files with 8 additions and 0 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue