Skip to content

Commit

Permalink
Merge branch 'bcgov-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ann-aot committed Feb 22, 2021
2 parents 8c87438 + 3e9ee11 commit dace5e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions api/app/resources/theq/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from app.auth.auth import jwt
from app.models.theq import CSR, Office
from qsystem import socketio, my_print
from flask_jwt_oidc.exceptions import AuthError


@socketio.on('joinRoom')
Expand Down Expand Up @@ -72,3 +73,9 @@ def clear_csr_user_id(csr_id):
@socketio.on('sync_offices_cache')
def sync_offices_cache():
Office.clear_offices_cache()


@socketio.on_error()
def error_handler(e):
# Passing the execution as it would be an auth error with invalid token.
print('Socket error ', e)
7 changes: 7 additions & 0 deletions api/qsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from sqlalchemy.exc import SQLAlchemyError
from app.exceptions import AuthError
from flask_jwt_oidc.exceptions import AuthError as JwtAuthError
from jose.exceptions import JOSEError
from sqlalchemy import event
from sqlalchemy.engine import Engine

Expand Down Expand Up @@ -362,6 +363,12 @@ def handle_jwt_auth_error(error):
return error.error, error.status_code


@application.errorhandler(JOSEError)
@api.errorhandler(JOSEError)
def handle_jose_jwt_error(error):
return {}, 401


@event.listens_for(Engine, "before_cursor_execute")
def before_cursor_execute(conn, cursor, statement,
parameters, context, executemany):
Expand Down

0 comments on commit dace5e8

Please sign in to comment.