<commit_before>package controllers.v1

import akka.actor.ActorSystem
import be.objectify.deadbolt.scala.ActionBuilders
import be.objectify.deadbolt.scala.models.PatternType
import com.google.inject._
import org.birdfeed.chirp.actions.ActionWithValidApiKey
import org.birdfeed.chirp.database.models.{AccessToken, User}
import play.api.libs.functional.syntax._
import play.api.libs.json._
import play.api.mvc._

import scala.concurrent._


@Singleton
class UserController @Inject()(actorSystem: ActorSystem, actionBuilder: ActionBuilders)(implicit exec: ExecutionContext) extends Controller {

  def authenticate = ActionWithValidApiKey {
    Action.async(BodyParsers.parse.json) { request =>
      implicit val authenticateReads: Reads[Option[Result]] = (
        (JsPath \ "email").read[String] and
        (JsPath \ "password").read[String]
      )((email: String, password: String) => {
        User.authenticate(email, password)
          .map { token => Ok(token.toJson("userId", "token", "refreshToken")) }
      })<commit_msg>return roleId in json blob<commit_after>package controllers.v1

import akka.actor.ActorSystem
import be.objectify.deadbolt.scala.ActionBuilders
import be.objectify.deadbolt.scala.models.PatternType
import com.google.inject._
import org.birdfeed.chirp.actions.ActionWithValidApiKey
import org.birdfeed.chirp.database.models.{AccessToken, User}
import play.api.libs.functional.syntax._
import play.api.libs.json._
import play.api.mvc._

import scala.concurrent._


@Singleton
class UserController @Inject()(actorSystem: ActorSystem, actionBuilder: ActionBuilders)(implicit exec: ExecutionContext) extends Controller {

  def authenticate = ActionWithValidApiKey {
    Action.async(BodyParsers.parse.json) { request =>
      implicit val authenticateReads: Reads[Option[Result]] = (
        (JsPath \ "email").read[String] and
        (JsPath \ "password").read[String]
      )((email: String, password: String) => {
        User.authenticate(email, password)
          .map { token => Ok(token.toJson("userId", "token", "refreshToken", "roleId")) }
      })
{'fraction_non_alphanumeric': 0.12026832774317202, 'fraction_numerical': 0.0009583133684714902, 'mean_word_length': 4.5828877005347595, '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': '6599019', 'n_tokens_mistral': 646, 'n_tokens_neox': 621, 'n_words': 123}