From f5fa8e96c15db5a1848e74accbe5686575628b34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Tue, 10 Sep 2024 10:56:28 +0200 Subject: [PATCH] bugfix/Fix term and conditions multiple saving --- obp-api/src/main/scala/code/model/dataAccess/AuthUser.scala | 2 +- obp-api/src/main/scala/code/snippet/TermsAndConditions.scala | 4 +++- obp-api/src/main/scala/code/users/UserAgreement.scala | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/obp-api/src/main/scala/code/model/dataAccess/AuthUser.scala b/obp-api/src/main/scala/code/model/dataAccess/AuthUser.scala index c5a4bf58a9..4dc05128f0 100644 --- a/obp-api/src/main/scala/code/model/dataAccess/AuthUser.scala +++ b/obp-api/src/main/scala/code/model/dataAccess/AuthUser.scala @@ -1045,7 +1045,7 @@ def restoreSomeSessions(): Unit = { .map(_.agreementHash).getOrElse(HashUtil.Sha256Hash("not set")) val agreementText = getWebUiPropsValue("webui_terms_and_conditions", "not set") val hashedAgreementText = HashUtil.Sha256Hash(agreementText) - if(hashedAgreementTextOfUser == hashedAgreementText) { // Chech terms and conditions + if(hashedAgreementTextOfUser == hashedAgreementText) { // Check terms and conditions val hashedAgreementTextOfUser = UserAgreementProvider.userAgreementProvider.vend.getUserAgreement(userId, "privacy_conditions") .map(_.agreementHash).getOrElse(HashUtil.Sha256Hash("not set")) diff --git a/obp-api/src/main/scala/code/snippet/TermsAndConditions.scala b/obp-api/src/main/scala/code/snippet/TermsAndConditions.scala index 5bbaa754a0..87e6393636 100644 --- a/obp-api/src/main/scala/code/snippet/TermsAndConditions.scala +++ b/obp-api/src/main/scala/code/snippet/TermsAndConditions.scala @@ -70,7 +70,9 @@ class TermsAndConditions extends MdcLoggable { val agreementText = getWebUiPropsValue("webui_terms_and_conditions", "not set") // val hashedAgreementText = HashUtil.Sha256Hash(agreementText) UserAgreementProvider.userAgreementProvider.vend.createOrUpdateUserAgreement( - AuthUser.currentUser.flatMap(_.user.foreign.map(_.userId)).getOrElse(""), "terms_and_conditions", agreementText) + AuthUser.currentUser.flatMap(_.user.foreign.map(_.userId)).getOrElse(""), + "terms_and_conditions", + agreementText) S.redirectTo("/") } } diff --git a/obp-api/src/main/scala/code/users/UserAgreement.scala b/obp-api/src/main/scala/code/users/UserAgreement.scala index 71be0b0627..ac51bfd865 100644 --- a/obp-api/src/main/scala/code/users/UserAgreement.scala +++ b/obp-api/src/main/scala/code/users/UserAgreement.scala @@ -82,7 +82,7 @@ object UserAgreement extends UserAgreement with LongKeyedMetaMapper[UserAgreemen agreement => tryo { val hash = HashUtil.Sha256Hash(agreement.agreementText) - agreement.AgreementHash(hash ).save + agreement.AgreementHash(hash) } )