Skip to content

Commit

Permalink
fixes5
Browse files Browse the repository at this point in the history
  • Loading branch information
sureshhmrc committed Jun 4, 2018
1 parent 3e5b8da commit bbe3ba0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import scala.concurrent.{ExecutionContext, Future}
class AuthConnector @Inject()(http: WSHttp, appConfig: AppConfig) extends Logging {

def loginAndGetToken()(implicit hc: HeaderCarrier, ec: ExecutionContext): Future[Either[String, Unit]] = {
http.post(appConfig.authStubUrl, Json.parse(getRequestBody())).map {
http.post(appConfig.authStubUrl, Json.parse(getRequestBody()), Map("Content-Type" -> "application/json")).map {
response
response.status match {
case Status.OK =>
logger.info(s"Got 200 from auth stub, response headers= ${response.allHeaders} and body=${response.body}")
case Status.NO_CONTENT =>
logger.info(s"Got 204 from auth stub, response headers= ${response.allHeaders} and body=${response.body}")
Right(())
case other: Int => Left(s"unexpected status during auth, got status=$other but 200 expected, response body=${response.body}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class HelpToSaveApiController @Inject()(http: WSHttp, authConnector: AuthConnect
val maybeToken = Option(tokenCache.getIfPresent("token"))

maybeToken match {
case Some(token) => logger.info("token exists in cache, not going through login processl")
case Some(token) => logger.info("token exists in cache, not going through login process")
case None =>
logger.info("no access token in the cache, getting the token and redirecting to getCheckEligibilityPage")
val p = authConnector.loginAndGetToken()
Expand All @@ -76,9 +76,9 @@ class HelpToSaveApiController @Inject()(http: WSHttp, authConnector: AuthConnect

tokenCache.put("token", accessToken)

logger.info(s"updated token cache with token: $accessToken")
logger.info(s"updated token cache with token: $accessToken, tokenCache.size()=${tokenCache.size()}")

SeeOther(accessToken)
NoContent

case other: Int =>
logger.warn(s"got $other status during get access_token, body=${response.body}")
Expand Down

0 comments on commit bbe3ba0

Please sign in to comment.