mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-08 06:25:51 +01:00
(refs #22)Fix constraint for adding collaborator.
This commit is contained in:
@@ -104,17 +104,12 @@ trait SettingsControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
private def collaborator: Constraint = new Constraint(){
|
private def collaborator: Constraint = new Constraint(){
|
||||||
def validate(name: String, value: String): Option[String] = {
|
def validate(name: String, value: String): Option[String] = {
|
||||||
|
val paths = request.getRequestURI.split("/")
|
||||||
getAccountByUserName(value) match {
|
getAccountByUserName(value) match {
|
||||||
case None => Some("User does not exist.")
|
case None => Some("User does not exist.")
|
||||||
case Some(x) if(x.userName == context.loginAccount.get.userName) => Some("User can access this repository already.")
|
case Some(x) if(x.userName == paths(1) || getCollaborators(paths(1), paths(2)).contains(x.userName))
|
||||||
case Some(x) => {
|
=> Some("User can access this repository already.")
|
||||||
val paths = request.getRequestURI.split("/")
|
case _ => None
|
||||||
if(getCollaborators(paths(1), paths(2)).contains(x.userName)){
|
|
||||||
Some("User can access this repository already.")
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user