<commit_before>package controllers

import play.api._
import play.api.mvc._
import play.api.data._
import play.api.data.Forms._
import play.api.i18n.Messages
import models._
import views._
import play.api.mvc.Security.AuthenticatedBuilder
import play.api.libs.json.Json
import scala.concurrent.Future
import play.api.mvc.Results._

object Login extends Controller {

  val loginForm: Form[User] = Form(
    mapping(
      "name" -> nonEmptyText,
      "pw" -> text) {
        (name, pw) => User(name, pw)
      } {
        user => Some(user.name, user.pw)
      })

  def login = Action { implicit request =>
    Ok(html.login.form(loginForm))
  }

  def logout = Action { implicit request =>
    Ok("loggedOut").withNewSession
  }

  def submit = Action { implicit request =>
    loginForm.bindFromRequest.fold(
      errors => Ok(html.login.form(errors)),
      requestUser => {
        val user: String = Play.current.configuration.getString("fillable.user").getOrElse("")
        val password: String = Play.current.configuration.getString("fillable.password").getOrElse("")
        if (requestUser.name.equals(user) && requestUser.pw.equals(password))
          Redirect(request.session.get("returnUrl").getOrElse("/")).withSession(session + ("user" -> requestUser.name) - "returnUrl")
        else
          Ok(html.login.form(loginForm, "error", Messages("error.wrongCredentials")))<commit_msg>Logout action leads to login form now<commit_after>package controllers

import play.api._
import play.api.mvc._
import play.api.data._
import play.api.data.Forms._
import play.api.i18n.Messages
import models._
import views._
import play.api.mvc.Security.AuthenticatedBuilder
import play.api.libs.json.Json
import scala.concurrent.Future
import play.api.mvc.Results._

object Login extends Controller {

  val loginForm: Form[User] = Form(
    mapping(
      "name" -> nonEmptyText,
      "pw" -> text) {
        (name, pw) => User(name, pw)
      } {
        user => Some(user.name, user.pw)
      })

  def login = Action { implicit request =>
    Ok(html.login.form(loginForm))
  }

  def logout = Action { implicit request =>
    Ok(html.login.form(loginForm)).withNewSession
  }

  def submit = Action { implicit request =>
    loginForm.bindFromRequest.fold(
      errors => Ok(html.login.form(errors)),
      requestUser => {
        val user: String = Play.current.configuration.getString("fillable.user").getOrElse("")
        val password: String = Play.current.configuration.getString("fillable.password").getOrElse("")
        if (requestUser.name.equals(user) && requestUser.pw.equals(password))
          Redirect(request.session.get("returnUrl").getOrElse("/")).withSession(session + ("user" -> requestUser.name) - "returnUrl")
        else
          Ok(html.login.form(loginForm, "error", Messages("error.wrongCredentials")))
{'fraction_non_alphanumeric': 0.13868356212601196, 'fraction_numerical': 0.0014079549454417458, 'mean_word_length': 3.406201550387597, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '1752172', 'n_tokens_mistral': 875, 'n_tokens_neox': 852, 'n_words': 173}