in membership-attribute-service/app/controllers/AttributeController.scala [254:276]
private def maybeAllowAccessToDigipackForGuardianEmployees(
user: UserFromToken,
maybeAttributes: Option[Attributes],
identityId: String,
): Option[Attributes] = {
val email = user.primaryEmailAddress
val allowDigiPackAccessToStaff =
(for {
userHasValidatedEmail <- user.userEmailValidated
emailDomain <- email.split("@").lastOption
userHasGuardianEmail = List("guardian.co.uk", "theguardian.com").contains(emailDomain)
} yield {
userHasValidatedEmail && userHasGuardianEmail
}).getOrElse(false)
// if maybeAttributes == None, there is nothing in Zuora so we have to hack it
lazy val mockedZuoraAttribs = Some(Attributes(identityId))
lazy val digipackAllowEmployeeAccessDateHack = Some(new LocalDate(2999, 1, 1))
if (allowDigiPackAccessToStaff)
(maybeAttributes orElse mockedZuoraAttribs).map(_.copy(DigitalSubscriptionExpiryDate = digipackAllowEmployeeAccessDateHack))
else
maybeAttributes
}