Browse Source

Merge pull request 'zouanp' (#190) from zouanp into V20210731.patch

Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/190
pull/192/head
lewis 3 years ago
parent
commit
c1a5425de8
2 changed files with 5 additions and 19 deletions
  1. +5
    -5
      routers/repo/attachment.go
  2. +0
    -14
      routers/repo/dataset.go

+ 5
- 5
routers/repo/attachment.go View File

@@ -152,15 +152,15 @@ func DownloadUserIsOrg(ctx *context.Context, attach *models.Attachment) bool {
} else { } else {
repo.GetOwner() repo.GetOwner()
if repo.Owner.IsOrganization() { if repo.Owner.IsOrganization() {
log.Info("ower is org.")
//log.Info("ower is org.")
if repo.Owner.IsUserPartOfOrg(ctx.User.ID) { if repo.Owner.IsUserPartOfOrg(ctx.User.ID) {
log.Info("user may be visit the attach.")
return false
log.Info("user may visit the attach.")
return true
} }
} }
} }
} }
return true
return false
} }


// GetAttachment serve attachements // GetAttachment serve attachements
@@ -190,7 +190,7 @@ func GetAttachment(ctx *context.Context) {


if repository == nil { //If not linked if repository == nil { //If not linked
//if !(ctx.IsSigned && attach.UploaderID == ctx.User.ID) && attach.IsPrivate { //We block if not the uploader //if !(ctx.IsSigned && attach.UploaderID == ctx.User.ID) && attach.IsPrivate { //We block if not the uploader
if !(ctx.IsSigned && attach.UploaderID == ctx.User.ID) && DownloadUserIsOrg(ctx, attach) { //We block if not the uploader
if !(ctx.IsSigned && attach.UploaderID == ctx.User.ID) && !DownloadUserIsOrg(ctx, attach) { //We block if not the uploader
ctx.Error(http.StatusNotFound) ctx.Error(http.StatusNotFound)
return return
} }


+ 0
- 14
routers/repo/dataset.go View File

@@ -22,20 +22,6 @@ func MustEnableDataset(ctx *context.Context) {
} }
} }


func filterPrivateAttachments(ctx *context.Context, list []*models.Attachment) []*models.Attachment {
if ctx.Repo.CanWrite(models.UnitTypeDatasets) {
return list
} else {
var publicList []*models.Attachment
for _, attach := range list {
if !attach.IsPrivate {
publicList = append(publicList, attach)
}
}
return publicList
}
}

func newFilterPrivateAttachments(ctx *context.Context, list []*models.Attachment, repo *models.Repository) []*models.Attachment { func newFilterPrivateAttachments(ctx *context.Context, list []*models.Attachment, repo *models.Repository) []*models.Attachment {


if ctx.Repo.CanWrite(models.UnitTypeDatasets) { if ctx.Repo.CanWrite(models.UnitTypeDatasets) {


Loading…
Cancel
Save