Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/202pull/217/head
@@ -151,18 +151,19 @@ func DownloadUserIsOrgOrCollaboration(ctx *context.Context, attach *models.Attac | |||||
log.Info("query repo error.") | log.Info("query repo error.") | ||||
} else { | } else { | ||||
repo.GetOwner() | 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 | return true | ||||
} | } | ||||
} | } | ||||
isCollaborator, _ := repo.IsCollaborator(ctx.User.ID) | |||||
if isCollaborator { | |||||
log.Info("Collaborator user may visit the attach.") | |||||
return true | |||||
} | |||||
} | } | ||||
} | } | ||||
return false | return false | ||||
@@ -32,13 +32,13 @@ func newFilterPrivateAttachments(ctx *context.Context, list []*models.Attachment | |||||
repo.GetOwner() | repo.GetOwner() | ||||
} | } | ||||
permission := false | permission := false | ||||
if repo.Owner.IsOrganization() { | |||||
if repo.Owner.IsOrganization() && ctx.User != nil { | |||||
if repo.Owner.IsUserPartOfOrg(ctx.User.ID) { | if repo.Owner.IsUserPartOfOrg(ctx.User.ID) { | ||||
log.Info("user is member of org.") | log.Info("user is member of org.") | ||||
permission = true | permission = true | ||||
} | } | ||||
} | } | ||||
if !permission { | |||||
if !permission && ctx.User != nil { | |||||
isCollaborator, _ := repo.IsCollaborator(ctx.User.ID) | isCollaborator, _ := repo.IsCollaborator(ctx.User.ID) | ||||
if isCollaborator { | if isCollaborator { | ||||
log.Info("Collaborator user may visit the attach.") | log.Info("Collaborator user may visit the attach.") | ||||