Browse Source

Merge pull request '增加游客访问时,用户信息为空的情况判断' (#202) from zouanp into V20210731.patch

Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/202
pull/217/head
lewis 3 years ago
parent
commit
c3c5309c4a
2 changed files with 12 additions and 11 deletions
  1. +10
    -9
      routers/repo/attachment.go
  2. +2
    -2
      routers/repo/dataset.go

+ 10
- 9
routers/repo/attachment.go View File

@@ -151,18 +151,19 @@ func DownloadUserIsOrgOrCollaboration(ctx *context.Context, attach *models.Attac
log.Info("query repo error.")
} else {
repo.GetOwner()
if repo.Owner.IsOrganization() {
//log.Info("ower is org.")
if repo.Owner.IsUserPartOfOrg(ctx.User.ID) {
log.Info("org user may visit the attach.")
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
}
}
isCollaborator, _ := repo.IsCollaborator(ctx.User.ID)
if isCollaborator {
log.Info("Collaborator user may visit the attach.")
return true
}
}
isCollaborator, _ := repo.IsCollaborator(ctx.User.ID)
if isCollaborator {
log.Info("Collaborator user may visit the attach.")
return true
}
}
}
return false


+ 2
- 2
routers/repo/dataset.go View File

@@ -32,13 +32,13 @@ func newFilterPrivateAttachments(ctx *context.Context, list []*models.Attachment
repo.GetOwner()
}
permission := false
if repo.Owner.IsOrganization() {
if repo.Owner.IsOrganization() && ctx.User != nil {
if repo.Owner.IsUserPartOfOrg(ctx.User.ID) {
log.Info("user is member of org.")
permission = true
}
}
if !permission {
if !permission && ctx.User != nil {
isCollaborator, _ := repo.IsCollaborator(ctx.User.ID)
if isCollaborator {
log.Info("Collaborator user may visit the attach.")


Loading…
Cancel
Save