diff --git a/bootstrap.py b/bootstrap.py index ba099a0..8316955 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -76,7 +76,7 @@ def home(): return Response(headers={'Access-Control-Allow-Origin': '*'}) -sh.debug_mode = True +sh.debug_mode = False threading.Thread(target=sh.expired_sessions_collector, daemon=True, args="5").start() app.run(port=15789, host="0.0.0.0", debug=sh.debug_mode) diff --git a/hub_api/control/session.py b/hub_api/control/session.py index 18fc783..3a1f37e 100644 --- a/hub_api/control/session.py +++ b/hub_api/control/session.py @@ -7,7 +7,7 @@ Copyright © 2022 Project Author name guillermo.gutierrezmorote@concordia.ca import datetime import json import uuid - +from sqlalchemy.exc import SQLAlchemyError from flask import request, Response from flask_restful import Resource @@ -25,7 +25,7 @@ class SessionStart(Resource, Config): try: application_uuid = uuid.UUID(request.headers.get('application-uuid', None)) user_info = self.database.user_login(name=username, password=password, application_uuid=application_uuid) - except ValueError: + except (ValueError, SQLAlchemyError, TypeError): return Response(json.dumps({'error': 'unauthorized'}), status=403) ip = request.remote_addr if user_info: diff --git a/hub_api/helpers/session_helper.py b/hub_api/helpers/session_helper.py index 5fff078..038506d 100644 --- a/hub_api/helpers/session_helper.py +++ b/hub_api/helpers/session_helper.py @@ -24,8 +24,6 @@ def expired_sessions_collector(session_timeout_duration): while True: if bool(sessions): for session_uuid in sessions: - print(sessions) - print(sessions[session_uuid]['expire']) _expire = datetime.datetime.strptime(sessions[session_uuid]['expire'], '%Y-%m-%d %H:%M:%S.%f') if _expire < datetime.datetime.now(): print("session for user: ", sessions[session_uuid]['user'], "expired.")