Redirect to previous URL after sign in.

This commit is contained in:
takezoe
2013-06-29 04:31:58 +09:00
parent b69e35f2d1
commit 9650cc48cc
3 changed files with 20 additions and 5 deletions

View File

@@ -18,8 +18,13 @@ abstract class ControllerBase extends ScalatraFilter
/**
* Returns the context object for the request.
*/
implicit def context: Context = Context(servletContext.getContextPath, LoginAccount)
implicit def context: Context = Context(servletContext.getContextPath, LoginAccount, currentURL)
private def currentURL: String = {
val queryString = request.getQueryString
request.getRequestURI + (if(queryString != null) "?" + queryString else "")
}
private def LoginAccount: Option[Account] = {
session.get("LOGIN_ACCOUNT") match {
case Some(x: Account) => Some(x)
@@ -79,4 +84,4 @@ abstract class ControllerBase extends ScalatraFilter
}
case class Context(path: String, loginAccount: Option[Account])
case class Context(path: String, loginAccount: Option[Account], currentUrl: String)