in app/controllers/Auth.scala [230:269]
private def finalCallbackResponse(maybeOAuthResponse:Either[String, OAuthResponse],
maybeOAuthClaims:Either[String, JWTClaimsSet],
maybeUserProfile:Either[String, UserProfile],
header:ResponseHeader,
entity: play.api.http.HttpEntity) = Future(
maybeOAuthResponse match {
case Left(err)=>
logger.error(s"Could not perform oauth exchange: $err")
InternalServerError(GenericErrorResponse("error",err).asJson)
case Right(oAuthResponse)=>
logger.debug(s"oauth exchange successful, got $oAuthResponse")
val baseSessionValues = Map[String,String]()
val claimsSessionValues = maybeOAuthClaims match {
case Left(err)=>
logger.warn(s"Could not get claims: $err")
baseSessionValues
case Right(claims)=>
baseSessionValues ++ Map(
"username"->claims.getUserID,
"claimExpiry"->ZonedDateTime
.ofInstant(claims.getExpirationTime.toInstant, ZoneId.systemDefault())
.format(DateTimeFormatter.ISO_DATE_TIME)
)
}
val sessionValues = maybeUserProfile match {
case Left(err)=>
logger.warn(s"Could not load user profile: $err")
claimsSessionValues
case Right(profile)=>
claimsSessionValues ++ Map("userProfile"->profile.asJson.noSpaces)
}
Result(
header,
entity
).withSession(Session(sessionValues))
}