From 62b3afeeedfe054345f86093e2d243e956c1e3c9 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Wed, 26 Feb 2020 11:27:31 +0100 Subject: The project is now using Poetry. --- src/web/lib/__init__.py | 0 src/web/lib/user_utils.py | 23 ----------------------- src/web/lib/view_utils.py | 26 -------------------------- 3 files changed, 49 deletions(-) delete mode 100644 src/web/lib/__init__.py delete mode 100644 src/web/lib/user_utils.py delete mode 100644 src/web/lib/view_utils.py (limited to 'src/web/lib') diff --git a/src/web/lib/__init__.py b/src/web/lib/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/web/lib/user_utils.py b/src/web/lib/user_utils.py deleted file mode 100644 index f78a6ed6..00000000 --- a/src/web/lib/user_utils.py +++ /dev/null @@ -1,23 +0,0 @@ - - -from itsdangerous import URLSafeTimedSerializer -import conf -from bootstrap import application - - -def generate_confirmation_token(nickname): - serializer = URLSafeTimedSerializer(application.config['SECRET_KEY']) - return serializer.dumps(nickname, salt=application.config['SECURITY_PASSWORD_SALT']) - - -def confirm_token(token): - serializer = URLSafeTimedSerializer(application.config['SECRET_KEY']) - try: - nickname = serializer.loads( - token, - salt=application.config['SECURITY_PASSWORD_SALT'], - max_age=conf.TOKEN_VALIDITY_PERIOD - ) - except: - return False - return nickname diff --git a/src/web/lib/view_utils.py b/src/web/lib/view_utils.py deleted file mode 100644 index 1d8c6aed..00000000 --- a/src/web/lib/view_utils.py +++ /dev/null @@ -1,26 +0,0 @@ -from functools import wraps -from flask import request, Response, make_response -from lib.utils import to_hash - - -def etag_match(func): - @wraps(func) - def wrapper(*args, **kwargs): - response = func(*args, **kwargs) - if isinstance(response, Response): - etag = to_hash(response.data) - headers = response.headers - elif type(response) is str: - etag = to_hash(response) - headers = {} - else: - return response - if request.headers.get('if-none-match') == etag: - response = Response(status=304) - response.headers['Cache-Control'] \ - = headers.get('Cache-Control', 'pragma: no-cache') - elif not isinstance(response, Response): - response = make_response(response) - response.headers['etag'] = etag - return response - return wrapper -- cgit