Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong behavior during full update with expiration date #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading