in api/src/main/scala/com/gu/adapters/http/Authentication.scala [57:79]
private def authenticateUserWithIdapi(
scGuUCookie: Option[String]
): Either[Error, User] = {
// Attempt to authenticate user.
val result = for {
value <- IO.fromEither(
Either.fromOption(
scGuUCookie,
new Exception("No secure cookie in request")
)
)
credentials = IdapiUserCredentials.SCGUUCookie(value)
identityId <- idapiAuthService.authenticateUser(credentials)
} yield identityId
result
.redeem(
err =>
Left(userAuthorizationFailed(List(err.getMessage)): Error),
identityId => Right(User(identityId))
)
.unsafeRunSync()
}