(refs #22)Fix constraint for adding collaborator.

This commit is contained in:
takezoe
2013-07-08 15:23:40 +09:00
parent 5150b4b1b6
commit 97101248a2

View File

@@ -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
}
}
} }
} }
} }