mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 15:05:50 +01:00
(refs #279)Override ScalatraBase#fullUrl() to apply the configured base url to redirection.
This commit is contained in:
@@ -103,15 +103,21 @@ abstract class ControllerBase extends ScalatraFilter
|
|||||||
if(request.getMethod.toUpperCase == "POST"){
|
if(request.getMethod.toUpperCase == "POST"){
|
||||||
org.scalatra.Unauthorized(redirect("/signin"))
|
org.scalatra.Unauthorized(redirect("/signin"))
|
||||||
} else {
|
} else {
|
||||||
val currentUrl = baseUrl + defining(request.getQueryString){ queryString =>
|
org.scalatra.Unauthorized(redirect("/signin?redirect=" + StringUtil.urlEncode(
|
||||||
|
defining(request.getQueryString){ queryString =>
|
||||||
request.getRequestURI.substring(request.getContextPath.length) + (if(queryString != null) "?" + queryString else "")
|
request.getRequestURI.substring(request.getContextPath.length) + (if(queryString != null) "?" + queryString else "")
|
||||||
}
|
}
|
||||||
session.setAttribute(Keys.Session.Redirect, currentUrl)
|
)))
|
||||||
org.scalatra.Unauthorized(redirect("/signin"))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override def fullUrl(path: String, params: Iterable[(String, Any)] = Iterable.empty,
|
||||||
|
includeContextPath: Boolean = true, includeServletPath: Boolean = true)
|
||||||
|
(implicit request: HttpServletRequest, response: HttpServletResponse) =
|
||||||
|
if (path.startsWith("http")) path
|
||||||
|
else baseUrl + url(path, params, includeContextPath, includeServletPath)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import util._
|
import util._
|
||||||
import util.Implicits._
|
|
||||||
import service._
|
import service._
|
||||||
import jp.sf.amateras.scalatra.forms._
|
import jp.sf.amateras.scalatra.forms._
|
||||||
|
|
||||||
@@ -31,8 +30,7 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
get("/signin"){
|
get("/signin"){
|
||||||
val redirect = params.get("redirect")
|
val redirect = params.get("redirect")
|
||||||
if(redirect.isDefined && redirect.get.startsWith("/")){
|
if(redirect.isDefined && redirect.get.startsWith("/")){
|
||||||
|
flash += Keys.Flash.Redirect -> redirect.get
|
||||||
session.setAttribute(Keys.Session.Redirect, redirect.get)
|
|
||||||
}
|
}
|
||||||
html.signin(loadSystemSettings())
|
html.signin(loadSystemSettings())
|
||||||
}
|
}
|
||||||
@@ -56,7 +54,7 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
session.setAttribute(Keys.Session.LoginAccount, account)
|
session.setAttribute(Keys.Session.LoginAccount, account)
|
||||||
updateLastLoginDate(account.userName)
|
updateLastLoginDate(account.userName)
|
||||||
|
|
||||||
session.getAndRemove[String](Keys.Session.Redirect).map { redirectUrl =>
|
flash.get(Keys.Flash.Redirect).asInstanceOf[Option[String]].map { redirectUrl =>
|
||||||
if(redirectUrl.replaceFirst("/$", "") == request.getContextPath){
|
if(redirectUrl.replaceFirst("/$", "") == request.getContextPath){
|
||||||
redirect("/")
|
redirect("/")
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user