Skip to content
Snippets Groups Projects
Commit 091bb8f6 authored by Leonardo Menezes's avatar Leonardo Menezes
Browse files

handle custom base path correctly on logout

closes #142
parent bcbc3d8e
No related branches found
No related tags found
No related merge requests found
......@@ -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
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment