mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 21:45:50 +01:00
Authentication functions should be separate from ControllerBase as trait?
This commit is contained in:
@@ -5,7 +5,7 @@ import org.scalatra._
|
||||
import org.scalatra.json._
|
||||
import org.json4s._
|
||||
import jp.sf.amateras.scalatra.forms._
|
||||
import service.AccountService
|
||||
import service._
|
||||
|
||||
/**
|
||||
* Provides generic features for ScalatraServlet implementations.
|
||||
@@ -76,6 +76,49 @@ abstract class ControllerBase extends ScalatraFilter with ClientSideValidationFo
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Allows only collaborators and administrators.
|
||||
// */
|
||||
// protected def collaboratorsOnly(action: => Any) = {
|
||||
// {
|
||||
// context.loginAccount match {
|
||||
// case Some(x) if(x.userType == AccountService.Administrator) => action
|
||||
// case Some(x) if(request.getRequestURI.split("/")(1) == x.userName) => action
|
||||
// case Some(x) => {
|
||||
// val paths = request.getRequestURI.split("/")
|
||||
// if(getCollaborators(paths(1), paths(2)).contains(x.userName)){
|
||||
// action
|
||||
// } else {
|
||||
// redirect("/signin")
|
||||
// }
|
||||
// }
|
||||
// case None => redirect("/signin")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Allows only collaborators and administrators.
|
||||
// */
|
||||
// protected def collaboratorsOnly[T](action: T => Any) = {
|
||||
// (form: T) => {
|
||||
// context.loginAccount match {
|
||||
// case Some(x) if(x.userType == AccountService.Administrator) => action(form)
|
||||
// case Some(x) if(request.getRequestURI.split("/")(1) == x.userName) => action(form)
|
||||
// case Some(x) => {
|
||||
// val paths = request.getRequestURI.split("/")
|
||||
// if(getCollaborators(paths(1), paths(2)).contains(x.userName)){
|
||||
// action(form)
|
||||
// } else {
|
||||
// redirect("/signin")
|
||||
// }
|
||||
// }
|
||||
// case None => redirect("/signin")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// protected def adminOnly()
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user