From 4dd8896de78f615d25d6e0731e3a45ee0b7c7bee Mon Sep 17 00:00:00 2001 From: jasquat Date: Tue, 14 Feb 2023 15:08:25 -0500 Subject: [PATCH] commit user if it has changed any attributes w/ burnettk --- .../services/authorization_service.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py index bb63cf49..55b03af9 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py @@ -519,8 +519,16 @@ class AuthorizationService: user_model = UserService().create_user(**user_attributes) else: # Update with the latest information + user_db_model_changed = False for key, value in user_attributes.items(): - setattr(user_model, key, value) + current_value = getattr(user_model, key) + if current_value != value: + user_db_model_changed = True + setattr(user_model, key, value) + + if user_db_model_changed: + db.session.add(user_model) + db.session.commit() # this may eventually get too slow. # when it does, be careful about backgrounding, because