summaryrefslogtreecommitdiffstats
path: root/routers/repo
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-05-08 01:20:23 +0800
committertechknowlogick <hello@techknowlogick.com>2019-05-07 13:20:23 -0400
commit9f18b231295a6282111a1f058f0c973da50b5fd4 (patch)
treeea90521aba7a1ca52c55cb61c6cb898b8d98c7f8 /routers/repo
parent9139f35ff62927d23ee7a590a0987e8c12127bea (diff)
downloadgitea-9f18b231295a6282111a1f058f0c973da50b5fd4.tar.gz
gitea-9f18b231295a6282111a1f058f0c973da50b5fd4.zip
Fix 404 when send pull request some situation (#6871)
Diffstat (limited to 'routers/repo')
-rw-r--r--routers/repo/pull.go26
1 files changed, 22 insertions, 4 deletions
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index 70a1443e8a..d1e2f0b0b3 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -710,17 +710,35 @@ func ParseCompareInfo(ctx *context.Context) (*models.User, *models.Repository, *
}
}
- perm, err := models.GetUserRepoPermission(headRepo, ctx.User)
+ // user should have permission to read baseRepo's codes and pulls, NOT headRepo's
+ permBase, err := models.GetUserRepoPermission(baseRepo, ctx.User)
if err != nil {
ctx.ServerError("GetUserRepoPermission", err)
return nil, nil, nil, nil, "", ""
}
- if !perm.CanReadIssuesOrPulls(true) {
+ if !permBase.CanReadIssuesOrPulls(true) || !permBase.CanRead(models.UnitTypeCode) {
if log.IsTrace() {
- log.Trace("Permission Denied: User: %-v cannot create/read pull requests in Repo: %-v\nUser in headRepo has Permissions: %-+v",
+ log.Trace("Permission Denied: User: %-v cannot create/read pull requests or cannot read code in Repo: %-v\nUser in baseRepo has Permissions: %-+v",
+ ctx.User,
+ baseRepo,
+ permBase)
+ }
+ ctx.NotFound("ParseCompareInfo", nil)
+ return nil, nil, nil, nil, "", ""
+ }
+
+ // user should have permission to read headrepo's codes
+ permHead, err := models.GetUserRepoPermission(headRepo, ctx.User)
+ if err != nil {
+ ctx.ServerError("GetUserRepoPermission", err)
+ return nil, nil, nil, nil, "", ""
+ }
+ if !permHead.CanRead(models.UnitTypeCode) {
+ if log.IsTrace() {
+ log.Trace("Permission Denied: User: %-v cannot read code requests in Repo: %-v\nUser in headRepo has Permissions: %-+v",
ctx.User,
headRepo,
- perm)
+ permHead)
}
ctx.NotFound("ParseCompareInfo", nil)
return nil, nil, nil, nil, "", ""