mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-01 19:15:59 +01:00
(refs #279)Fix redirect URL generation in authentication.
This commit is contained in:
@@ -59,11 +59,6 @@ abstract class ControllerBase extends ScalatraFilter
|
|||||||
*/
|
*/
|
||||||
implicit def context: Context = Context(servletContext.getContextPath, LoginAccount, request)
|
implicit def context: Context = Context(servletContext.getContextPath, LoginAccount, request)
|
||||||
|
|
||||||
// TODO This method should be remvoved.
|
|
||||||
private def currentURL: String = defining(request.getQueryString){ queryString =>
|
|
||||||
request.getRequestURI + (if(queryString != null) "?" + queryString else "")
|
|
||||||
}
|
|
||||||
|
|
||||||
private def LoginAccount: Option[Account] = session.getAs[Account](Keys.Session.LoginAccount)
|
private def LoginAccount: Option[Account] = session.getAs[Account](Keys.Session.LoginAccount)
|
||||||
|
|
||||||
def ajaxGet(path : String)(action : => Any) : Route =
|
def ajaxGet(path : String)(action : => Any) : Route =
|
||||||
@@ -107,8 +102,11 @@ 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 {
|
||||||
// TODO This URL may not be same as the front URL...
|
val currentUrl = baseUrl + defining(request.getQueryString){ queryString =>
|
||||||
org.scalatra.Unauthorized(redirect("/signin?redirect=" + StringUtil.urlEncode(currentURL)))
|
request.getRequestURI.substring(request.getContextPath.length) + (if(queryString != null) "?" + queryString else "")
|
||||||
|
}
|
||||||
|
session.setAttribute(Keys.Session.Redirect, currentUrl)
|
||||||
|
org.scalatra.Unauthorized(redirect("/signin"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,7 +115,7 @@ abstract class ControllerBase extends ScalatraFilter
|
|||||||
defining(request.getRequestURL.toString){ url =>
|
defining(request.getRequestURL.toString){ url =>
|
||||||
url.substring(0, url.length - (request.getRequestURI.length - request.getContextPath.length))
|
url.substring(0, url.length - (request.getRequestURI.length - request.getContextPath.length))
|
||||||
}
|
}
|
||||||
}
|
}.replaceFirst("/$", "")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user