From 6eb4949154ff5f91c3d22c5428104bc84985bf6c Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 16 Jun 2022 10:25:01 +0800 Subject: [PATCH 1/3] fix-2208 --- routers/repo/dataset.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index d3ae1624b..e4272c053 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -623,10 +623,16 @@ func DatasetIsCollaborator(ctx *context.Context, DatasetID int64) bool { if ctx.User != nil { if repo.Owner.IsOrganization() { if repo.Owner.IsUserPartOfOrg(ctx.User.ID) { - log.Info("org user may visit the attach.") - return true + for _, t := range repo.Owner.Teams { + if t.IsMember(ctx.User.ID) && t.HasRepository(repo.ID) { + return true + } + } + log.Info("org user can visit the attach.") + return false } } + isCollaborator, _ := repo.IsCollaborator(ctx.User.ID) if isCollaborator { log.Info("Collaborator user may visit the attach.") From 0f1a2e79d4d81688440239983f6e6daf61d597de Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 16 Jun 2022 11:04:27 +0800 Subject: [PATCH 2/3] fix-2208 --- routers/repo/dataset.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index e4272c053..6a0253bb2 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -522,7 +522,6 @@ func MyFavoriteDataset(ctx *context.Context) { } datasets := IsColDatasets count := NotColcount + IsColcount - //排序 sort.Slice(datasets, func(i, j int) bool { return datasets[i].Attachment.CreatedUnix > datasets[j].Attachment.CreatedUnix }) @@ -613,7 +612,8 @@ func GetDatasetStatus(ctx *context.Context) { func DatasetIsCollaborator(ctx *context.Context, DatasetID int64) bool { dataset, err := models.GetDatasetByID(DatasetID) if err != nil { - log.Info("query dataset error") + log.Info("query dataset error:", DatasetID) + return false } else { repo, err := models.GetRepositoryByID(dataset.RepoID) if err != nil { From d1899170787b1c670a1e090561ad115a1183e348 Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 16 Jun 2022 11:11:43 +0800 Subject: [PATCH 3/3] fix-2208 --- routers/repo/dataset.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 6a0253bb2..3bc7cb97c 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -612,12 +612,12 @@ func GetDatasetStatus(ctx *context.Context) { func DatasetIsCollaborator(ctx *context.Context, DatasetID int64) bool { dataset, err := models.GetDatasetByID(DatasetID) if err != nil { - log.Info("query dataset error:", DatasetID) + log.Error("query dataset error:", err.Error()) return false } else { repo, err := models.GetRepositoryByID(dataset.RepoID) if err != nil { - log.Info("query repo error.") + log.Error("query repo error:", err.Error()) } else { repo.GetOwner() if ctx.User != nil { @@ -628,14 +628,12 @@ func DatasetIsCollaborator(ctx *context.Context, DatasetID int64) bool { return true } } - log.Info("org user can visit the attach.") return false } } isCollaborator, _ := repo.IsCollaborator(ctx.User.ID) if isCollaborator { - log.Info("Collaborator user may visit the attach.") return true } }