<commit_before>package controllers



import play.api._
import play.api.libs.concurrent._
import play.api.libs.concurrent.Execution.Implicits._
import libs.openid.{UserInfo, OpenID}
import play.api.mvc._
import play.api.mvc.Results._
import concurrent.Future
import scala.util.{Try,Success,Failure}

/**
 * Provide security features
 */
trait Secured {
  val REQUIRED_ATTRIBUTES=Seq(
    "email" -> "http://schema.openid.net/contact/email"
  )
  /**
   * Retrieve the connected user email.
   */
  private def username(request: RequestHeader) = request.session.get("email")

  /**
   * Redirect to login if the user in not authorized.
   */
  private def onUnauthorized(request: RequestHeader) = {
    Logger.info("Unauthorized access to "+request.uri+" , redirecting to "+routes.Application.authenticate())

    Redirect(routes.Application.authenticate())
  }

  // ---

  /**
   * Action for authenticated users.
   */
  def IsAuthenticated(f: => String => Request[AnyContent] => Result): Action[(Action[AnyContent], AnyContent)] = Security.Authenticated(username, onUnauthorized) {
    userId =>
      Action({
        request =>
          Logger.info("Authorized access to " + request.uri + " , for user " + userId)
          f(userId)(request)
      })
  }

  /**
   * Action for authenticated users.
   */
  def IsAuthenticated[A](parser: BodyParser[A])(f: => String => Request[A] => Result) = Security.Authenticated(username, onUnauthorized) {
    user =>
      Action(parser)(request => f(user)(request))
  }
}

trait XStaffing {
  this: Controller with Secured=>
  def index = IsAuthenticated { userid => implicit request => controllers.Assets.at("/public","index.html")(request) }

  def authenticate = Action { implicit request =>
      val openIdCallbackUrl: String = routes.Application.openIDCallback().absoluteURL()
      def onRedirected(promise: NotWaiting[String]): Result = {<commit_msg>move REQUIRED_ATTRIBUTE to the correct scope<commit_after>package controllers



import play.api._
import play.api.libs.concurrent._
import play.api.libs.concurrent.Execution.Implicits._
import libs.openid.{UserInfo, OpenID}
import play.api.mvc._
import play.api.mvc.Results._
import concurrent.Future
import scala.util.{Try,Success,Failure}

/**
 * Provide security features
 */
trait Secured {

  /**
   * Retrieve the connected user email.
   */
  private def username(request: RequestHeader) = request.session.get("email")

  /**
   * Redirect to login if the user in not authorized.
   */
  private def onUnauthorized(request: RequestHeader) = {
    Logger.info("Unauthorized access to "+request.uri+" , redirecting to "+routes.Application.authenticate())

    Redirect(routes.Application.authenticate())
  }

  // ---

  /**
   * Action for authenticated users.
   */
  def IsAuthenticated(f: => String => Request[AnyContent] => Result): Action[(Action[AnyContent], AnyContent)] = Security.Authenticated(username, onUnauthorized) {
    userId =>
      Action({
        request =>
          Logger.info("Authorized access to " + request.uri + " , for user " + userId)
          f(userId)(request)
      })
  }

  /**
   * Action for authenticated users.
   */
  def IsAuthenticated[A](parser: BodyParser[A])(f: => String => Request[A] => Result) = Security.Authenticated(username, onUnauthorized) {
    user =>
      Action(parser)(request => f(user)(request))
  }
}

trait XStaffing {
  this: Controller with Secured=>
  def index = IsAuthenticated { userid => implicit request => controllers.Assets.at("/public","index.html")(request) }

  val REQUIRED_ATTRIBUTES=Seq(
    "email" -> "http://schema.openid.net/contact/email"
  )

  def authenticate = Action { implicit request =>
      val openIdCallbackUrl: String = routes.Application.openIDCallback().absoluteURL()
      def onRedirected(promise: NotWaiting[String]): Result = {
{'fraction_non_alphanumeric': 0.1358313817330211, 'fraction_numerical': 0.0, 'mean_word_length': 3.7223587223587224, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, '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': '3846815', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1139, 'n_words': 253}