<commit_before>package com.ubirch.auth.server.route

import com.ubirch.auth.config.Config
import com.ubirch.auth.core.actor.TokenActor
import com.ubirch.auth.core.actor.util.ActorNames
import com.ubirch.auth.model.token.AfterLogin
import com.ubirch.auth.util.server.RouteConstants
import com.ubirch.util.http.response.ResponseUtil
import com.ubirch.util.json.MyJsonProtocol
import com.ubirch.util.rest.akka.directives.CORSDirective

import akka.actor.{ActorSystem, Props}
import akka.http.scaladsl.server.Route
import akka.pattern.ask
import akka.routing.RoundRobinPool
import akka.util.Timeout
import de.heikoseeberger.akkahttpjson4s.Json4sSupport._

import scala.concurrent.ExecutionContextExecutor
import scala.concurrent.duration._
import scala.language.postfixOps

/**
  * author: cvandrei
  * since: 2017-01-31
  */
trait TokenRoute extends MyJsonProtocol
  with CORSDirective
  with ResponseUtil {

  implicit val system = ActorSystem()
  implicit val executionContext: ExecutionContextExecutor = system.dispatcher
  implicit val timeout = Timeout(Config.actorTimeout seconds)

  // TODO extract anything performance related to config
  private val tokenActor = system.actorOf(new RoundRobinPool(3).props(Props[TokenActor]), ActorNames.TOKEN)

  val route: Route = {

    path(RouteConstants.token / RouteConstants.verify) {
      respondWithCORS {

        post {
          entity(as[AfterLogin]) { afterLogin =>
            onSuccess(tokenActor ? afterLogin) {
              case res: AfterLogin => complete(afterLogin)
              case _ => complete(serverErrorResponse(errorType = "VerificationError", errorMessage = "failed to verify token"))
            }
          }
        }

      }
    }

  }

}<commit_msg>changed error message text<commit_after>package com.ubirch.auth.server.route

import com.ubirch.auth.config.Config
import com.ubirch.auth.core.actor.TokenActor
import com.ubirch.auth.core.actor.util.ActorNames
import com.ubirch.auth.model.token.AfterLogin
import com.ubirch.auth.util.server.RouteConstants
import com.ubirch.util.http.response.ResponseUtil
import com.ubirch.util.json.MyJsonProtocol
import com.ubirch.util.rest.akka.directives.CORSDirective

import akka.actor.{ActorSystem, Props}
import akka.http.scaladsl.server.Route
import akka.pattern.ask
import akka.routing.RoundRobinPool
import akka.util.Timeout
import de.heikoseeberger.akkahttpjson4s.Json4sSupport._

import scala.concurrent.ExecutionContextExecutor
import scala.concurrent.duration._
import scala.language.postfixOps

/**
  * author: cvandrei
  * since: 2017-01-31
  */
trait TokenRoute extends MyJsonProtocol
  with CORSDirective
  with ResponseUtil {

  implicit val system = ActorSystem()
  implicit val executionContext: ExecutionContextExecutor = system.dispatcher
  implicit val timeout = Timeout(Config.actorTimeout seconds)

  // TODO extract anything performance related to config
  private val tokenActor = system.actorOf(new RoundRobinPool(3).props(Props[TokenActor]), ActorNames.TOKEN)

  val route: Route = {

    path(RouteConstants.token / RouteConstants.verify) {
      respondWithCORS {

        post {
          entity(as[AfterLogin]) { afterLogin =>
            onSuccess(tokenActor ? afterLogin) {
              case res: AfterLogin => complete(afterLogin)
              case _ => complete(serverErrorResponse(errorType = "VerificationError", errorMessage = "failed to verify code"))
            }
          }
        }

      }
    }

  }

}
{'fraction_non_alphanumeric': 0.09059434506635891, 'fraction_numerical': 0.006347374495095211, 'mean_word_length': 3.8557422969187676, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5936727', 'n_tokens_mistral': 1054, 'n_tokens_neox': 1032, 'n_words': 201}