mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 22:15: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(){
|
||||
def validate(name: String, value: String): Option[String] = {
|
||||
val paths = request.getRequestURI.split("/")
|
||||
getAccountByUserName(value) match {
|
||||
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) => {
|
||||
val paths = request.getRequestURI.split("/")
|
||||
if(getCollaborators(paths(1), paths(2)).contains(x.userName)){
|
||||
Some("User can access this repository already.")
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
case Some(x) if(x.userName == paths(1) || getCollaborators(paths(1), paths(2)).contains(x.userName))
|
||||
=> Some("User can access this repository already.")
|
||||
case _ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user