mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-05 04:56:02 +01:00
Merge branch 'master' of https://github.com/takezoe/gitbucket.git
This commit is contained in:
@@ -18,7 +18,12 @@ abstract class ControllerBase extends ScalatraFilter
|
|||||||
/**
|
/**
|
||||||
* Returns the context object for the request.
|
* 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] = {
|
private def LoginAccount: Option[Account] = {
|
||||||
session.get("LOGIN_ACCOUNT") match {
|
session.get("LOGIN_ACCOUNT") match {
|
||||||
@@ -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)
|
||||||
@@ -15,6 +15,10 @@ trait SignInControllerBase extends ControllerBase { self: SystemSettingsService
|
|||||||
)(SignInForm.apply)
|
)(SignInForm.apply)
|
||||||
|
|
||||||
get("/signin"){
|
get("/signin"){
|
||||||
|
val queryString = request.getQueryString
|
||||||
|
if(queryString.startsWith("/")){
|
||||||
|
session.setAttribute("REDIRECT", queryString)
|
||||||
|
}
|
||||||
html.signin(loadSystemSettings())
|
html.signin(loadSystemSettings())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +29,13 @@ trait SignInControllerBase extends ControllerBase { self: SystemSettingsService
|
|||||||
} else {
|
} else {
|
||||||
session.setAttribute("LOGIN_ACCOUNT", account.get)
|
session.setAttribute("LOGIN_ACCOUNT", account.get)
|
||||||
updateLastLoginDate(account.get.userName)
|
updateLastLoginDate(account.get.userName)
|
||||||
redirect("/%s".format(account.get.userName))
|
|
||||||
|
session.get("REDIRECT").map { redirectUrl =>
|
||||||
|
session.removeAttribute("REDIRECT")
|
||||||
|
redirect(redirectUrl.asInstanceOf[String])
|
||||||
|
}.getOrElse {
|
||||||
|
redirect("/%s".format(account.get.userName))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,10 +41,12 @@
|
|||||||
@if(loginAccount.isDefined){
|
@if(loginAccount.isDefined){
|
||||||
<li><a href="@path/new">New repo</a></li>
|
<li><a href="@path/new">New repo</a></li>
|
||||||
<li><a href="@url(loginAccount.get.userName)">Account</a></li>
|
<li><a href="@url(loginAccount.get.userName)">Account</a></li>
|
||||||
<li><a href="@path/admin/users">Administration</a></li>
|
@if(loginAccount.get.isAdmin){
|
||||||
|
<li><a href="@path/admin/users">Administration</a></li>
|
||||||
|
}
|
||||||
<li><a href="@path/signout">Sign out</a></li>
|
<li><a href="@path/signout">Sign out</a></li>
|
||||||
} else {
|
} else {
|
||||||
<li><a href="@path/signin">Sign in</a></li>
|
<li><a href="@path/signin?@currentUrl">Sign in</a></li>
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
</div><!--/.nav-collapse -->
|
</div><!--/.nav-collapse -->
|
||||||
|
|||||||
Reference in New Issue
Block a user