Fix Unauthorized error behaviour.

This commit is contained in:
takezoe
2013-06-29 22:42:40 +09:00
parent 800e11df0c
commit adfb71ea77

View File

@@ -69,9 +69,13 @@ abstract class ControllerBase extends ScalatraFilter
}
// TODO redirect to the sign-in page if not logged in?
protected def Unauthorized() = {
protected def Unauthorized()(implicit context: app.Context) = {
if(request.getAttribute("AJAX") == null){
org.scalatra.Unauthorized(redirect("/"))
if(context.loginAccount.isDefined){
org.scalatra.Unauthorized(redirect("/"))
} else {
org.scalatra.Unauthorized(redirect("/signin?" + currentURL))
}
} else {
org.scalatra.Unauthorized()
}