Fix users cannot visit issue attachment bug (#25019)

Caused by #24362

Co-authored-by: Giteabot <teabot@gitea.io>
pull/24986/head^2
Lunny Xiao 1 year ago committed by GitHub
parent 48bfea6705
commit 5d23c885ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      routers/web/repo/attachment.go
  2. 3
      tests/integration/attachment_test.go

@ -110,11 +110,6 @@ func ServeAttachment(ctx *context.Context, uuid string) {
return
}
} else { // If we have the repository we check access
context.CheckRepoScopedToken(ctx, repository)
if ctx.Written() {
return
}
perm, err := access_model.GetUserRepoPermission(ctx, repository, ctx.Doer)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetUserRepoPermission", err.Error())

@ -89,6 +89,9 @@ func TestCreateIssueAttachment(t *testing.T) {
// Validate that attachment is available
req = NewRequest(t, "GET", "/attachments/"+uuid)
session.MakeRequest(t, req, http.StatusOK)
// anonymous visit should be allowed because user2/repo1 is a public repository
MakeRequest(t, req, http.StatusOK)
}
func TestGetAttachment(t *testing.T) {

Loading…
Cancel
Save