correct response on invalid uuid
This commit is contained in:
parent
087cc7dc97
commit
ab4745bca9
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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.")
|
||||
|
|
Loading…
Reference in New Issue
Block a user