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? // 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){ if(request.getAttribute("AJAX") == null){
if(context.loginAccount.isDefined){
org.scalatra.Unauthorized(redirect("/")) org.scalatra.Unauthorized(redirect("/"))
} else {
org.scalatra.Unauthorized(redirect("/signin?" + currentURL))
}
} else { } else {
org.scalatra.Unauthorized() org.scalatra.Unauthorized()
} }