diff --git a/app/authentication/auth.py b/app/authentication/auth.py index 927fd197e..e61990749 100644 --- a/app/authentication/auth.py +++ b/app/authentication/auth.py @@ -8,6 +8,7 @@ from sqlalchemy.exc import DataError from sqlalchemy.orm.exc import NoResultFound from gds_metrics import Histogram +from app import db from app.dao.services_dao import dao_fetch_service_by_id from app.dao.api_key_dao import get_model_api_keys from app.serialised_models import ( @@ -123,6 +124,7 @@ def requires_auth(): try: service = get_service_model(issuer) service.api_keys = get_api_keys_models(issuer) + db.session.commit() except DataError: raise AuthError("Invalid token: service id is not the right data type", 403) except NoResultFound: diff --git a/app/notifications/validators.py b/app/notifications/validators.py index 40c14b86d..ea939a59e 100644 --- a/app/notifications/validators.py +++ b/app/notifications/validators.py @@ -8,6 +8,7 @@ from notifications_utils.recipients import ( ) from notifications_utils.clients.redis import rate_limit_cache_key, daily_limit_cache_key +from app import db from app.dao import services_dao, templates_dao from app.dao.service_sms_sender_dao import dao_get_service_sms_senders_by_id from app.models import ( @@ -160,7 +161,10 @@ def get_template_dict(template_id, service_id): raise BadRequestError(message=message, fields=[{'template': message}]) - return template_schema.dump(fetched_template).data + template_dict = template_schema.dump(fetched_template).data + + db.session.commit() + return template_dict def get_template_model(template_id, service_id):