diff --git a/app/controllers/AuthController.scala b/app/controllers/AuthController.scala index 9b9c435db778ae17134d91ecda2010585a0e1f4f..468881e4b0d50c60f58b576fb3bb31894f952ecb 100644 --- a/app/controllers/AuthController.scala +++ b/app/controllers/AuthController.scala @@ -5,15 +5,21 @@ import javax.inject.{Inject, Singleton} import akka.actor.ActorSystem import controllers.auth.{AuthAction, AuthenticationModule} import forms.LoginForm +import play.api.Configuration import play.api.mvc.{Action, Controller} + @Singleton -class AuthController @Inject()(system: ActorSystem, authentication: AuthenticationModule) extends Controller { +class AuthController @Inject()(system: ActorSystem, + authentication: AuthenticationModule, + configuration: Configuration) + extends Controller { import AuthController._ private val badFormMsg = "invalid login form data" + def index = Action { implicit request => if (authentication.isEnabled) { request.session.get(AuthAction.SESSION_USER).map { user => @@ -47,15 +53,15 @@ class AuthController @Inject()(system: ActorSystem, authentication: Authenticati } resp.withSession(AuthAction.SESSION_USER -> username) case None => - Redirect(routes.AuthController.index).flashing(LOGIN_MSG -> "wrong user and/or password") + Redirect(routes.AuthController.index).flashing(LOGIN_MSG -> "Incorrect username or password") } } ) } - def logout = Action { - request => - Redirect("/login").withNewSession + def logout = Action { _ => + val prefix = configuration.getString("play.http.context").getOrElse("/") + Redirect(s"${prefix}login").withNewSession } }