func checkOrgRepositoryPermission(user *models.User, namespace, repository string, permission int) bool { owner := false //Check Org exists org := new(models.Organization) if has, _, _ := org.Has(namespace); has == false { return false } //Check Owner, don't care Join team for _, k := range user.Organizations { if org.Id == k { owner = true } } //Check Repository repo := new(models.Repository) if has, _, _ := repo.Has(namespace, repository); has == false { if owner == true { return true } else { return false } } if repo.Privated == false && permission == PERMISSION_READ { return true } //Loop Team for _, k := range user.JoinTeams { team := new(models.Team) if err := team.GetById(k); err != nil { return false } //TODO Check Team Perimssion } return false }