Skip to content

Commit

Permalink
Fix wrong behavior during full update with expiration date
Browse files Browse the repository at this point in the history
  • Loading branch information
larousso committed Oct 24, 2024
1 parent 32dc1d6 commit 5e61315
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 2 additions & 3 deletions nio-server/app/controllers/ConsentController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,12 @@ class ConsentController(
NioLogger.error(s"error.userId.is.immutable : userId in path $userId // userId on body ${o.userId}")
Future.successful("error.userId.is.immutable".badRequest())
case Right(consentFact) =>
val cf: ConsentFact = ConsentFact.addOrgKey(consentFact, orgKey)
val cf: ConsentFact = ConsentFact.ignoreExpirationDates(ConsentFact.addOrgKey(consentFact, orgKey))

(cf.offers, req.authInfo.offerRestrictionPatterns) match {
// case ask create or update offers but no pattern allowed
case (Some(offers), None) =>
val errorMessages =
offers.map(o => ErrorMessage(s"offer.${o.key}.not.authorized"))
val errorMessages = offers.map(o => ErrorMessage(s"offer.${o.key}.not.authorized"))
NioLogger.error(s"not authorized : ${errorMessages.map(_.message)}")
Future.successful(AppErrors(errorMessages).unauthorized())

Expand Down
5 changes: 5 additions & 0 deletions nio-server/app/models/ConsentFact.scala
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,11 @@ object ConsentFact extends ReadableEntity[ConsentFact] {
case JsError(errors) => Left(AppErrors.fromJsError(errors))
}

def ignoreExpirationDates(consentFact: ConsentFact): ConsentFact =
consentFact.copy(groups = consentFact.groups.map(g =>
g.copy(consents = g.consents.map(c => c.copy(expiredAt = None)))
))

def addOrgKey(consentFact: ConsentFact, orgKey: String): ConsentFact =
consentFact.copy(orgKey = Some(orgKey))
}
Expand Down

0 comments on commit 5e61315

Please sign in to comment.