Skip to content

Commit

Permalink
Merge pull request #2421 from constantine2nd/develop
Browse files Browse the repository at this point in the history
/bugfix Terms and conditions multiple saving
  • Loading branch information
simonredfern authored Sep 10, 2024
2 parents cd18aeb + f6b2631 commit 0883fab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
4 changes: 3 additions & 1 deletion obp-api/src/main/scala/code/snippet/TermsAndConditions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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("/")
}
}
Expand Down
4 changes: 3 additions & 1 deletion obp-api/src/main/scala/code/users/UserAgreement.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import net.liftweb.mapper._
import net.liftweb.common.Box.tryo

object MappedUserAgreementProvider extends UserAgreementProvider {
// TODO Change the function name
override def createOrUpdateUserAgreement(userId: String, agreementType: String, agreementText: String): Box[UserAgreement] = {
UserAgreement.find(
By(UserAgreement.UserId, userId),
By(UserAgreement.AgreementType, agreementType)
) match {
// TODO We should be adding an additional record. Not changing existing one.
case Full(existingUser) =>
Full(
existingUser
Expand Down Expand Up @@ -80,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)
}
)

Expand Down

0 comments on commit 0883fab

Please sign in to comment.