<commit_before>package controllers.accounts

import play.Logger
import play.api.mvc.{ Session, Result, Controller, Action, RequestHeader }
import play.api.data.validation.Constraints
import play.api.i18n.Messages
import play.api.mvc.Flash
import securesocial.core.java.UserAwareAction
import securesocial.core.RuntimeEnvironment
import models.User
import service.InMemoryUserService
import service.UpdatableUserService
import scala.concurrent.Future
import scala.util.Success
import scala.util.Failure

class Index(override implicit val env: RuntimeEnvironment[User]) extends securesocial.core.SecureSocial[User] {

  val USER_SERVICE = env.userService.asInstanceOf[UpdatableUserService]

  def user(username: String) = UserAwareAction.async { implicit request =>
    def findUser(username: String) = USER_SERVICE.find(username)
    def showMyAccount(user: User) = Future { Ok(views.html.workspace.index(user)) }
    def showPublicAccount(username: String) = {
      val userFuture = findUser(username)
      userFuture.map {
        case Some(user) => Ok(views.html.workspace.index(user))
        case None       => Ok("This user doesn't exist")
      }
    }

    request.user match { //
      case Some(u) if u.username.get == username => showMyAccount(u)
      case Some(u)                               => showPublicAccount(username)
      case None                                  => showPublicAccount(username)
    }
  }

  def login = Action { implicit request =>
    Ok(views.html.login(null))
  }
}<commit_msg>Created a page for non existing users.<commit_after>package controllers.accounts

import play.Logger
import play.api.mvc.{ Session, Result, Controller, Action, RequestHeader }
import play.api.data.validation.Constraints
import play.api.i18n.Messages
import play.api.mvc.Flash
import securesocial.core.java.UserAwareAction
import securesocial.core.RuntimeEnvironment
import models.User
import service.InMemoryUserService
import service.UpdatableUserService
import scala.concurrent.Future
import scala.util.Success
import scala.util.Failure

class Index(override implicit val env: RuntimeEnvironment[User]) extends securesocial.core.SecureSocial[User] {

  val USER_SERVICE = env.userService.asInstanceOf[UpdatableUserService]

  def user(username: String) = UserAwareAction.async { implicit request =>
    def findUser(username: String) = USER_SERVICE.find(username)
    def showMyAccount(user: User) = Future { Ok(views.html.workspace.index(user)) }

    def showPublicAccount(username: String): Future[Result] = {
      val userFuture = findUser(username)
      userFuture.map {
        case Some(user) => Ok(views.html.workspace.index(user))
        case None       => Ok(views.html.workspace.notExistingUser(null))
      }
    }

    request.user match { //
      case Some(u) if u.username.get == username => showMyAccount(u)
      case Some(u)                               => showPublicAccount(username)
      case None                                  => showPublicAccount(username)
    }
  }

  def login = Action { implicit request =>
    Ok(views.html.login(null))
  }
}
{'fraction_non_alphanumeric': 0.09803289261528539, 'fraction_numerical': 0.0012899064817800709, 'mean_word_length': 3.508720930232558, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4874502', 'n_tokens_mistral': 891, 'n_tokens_neox': 873, 'n_words': 194}