Commit 42435dd1 authored by Leonardo Menezes's avatar Leonardo Menezes
Browse files

avoid using Play.current

parent fc0de8bd
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -5,30 +5,31 @@ import javax.inject.Inject
import controllers.auth.AuthenticationModule
import elastic.ElasticClient
import models.CerebroResponse
import play.api.Play
import play.api.Configuration
import play.api.libs.json.{JsArray, Json}
import play.api.mvc.Controller


class ConnectController @Inject()(val authentication: AuthenticationModule,
                                  config: Configuration,
                                  client: ElasticClient) extends Controller with AuthSupport {

  def index = AuthAction(authentication) {
    request => {
      val hosts = Play.current.configuration.getConfigSeq("hosts") match {
        case Some(configs) =>
          configs.map { config =>
            val username = config.getString("auth.username")
            val password = config.getString("auth.password")
      val hosts = config.getConfigSeq("hosts") match {
        case Some(hostsConfig) =>
          hostsConfig.map { hostConfig =>
            val username = hostConfig.getString("auth.username")
            val password = hostConfig.getString("auth.password")
            (username, password) match {
              case (Some(username), Some(password)) =>
                Json.obj(
                  "host" -> config.getString("host").get,
                  "host" -> hostConfig.getString("host").get,
                  "username" -> username,
                  "password" -> password
                )
              case _ =>
                Json.obj("host" -> config.getString("host").get)
                Json.obj("host" -> hostConfig.getString("host").get)
            }
          }
        case None =>