Check Push permissions on IsUserAllowedToUpdate (#11448)

release/v1.15
6543 2020-05-17 02:48:30 +02:00 committed by GitHub
parent dcb0cf7470
commit 84bcb3451a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -59,6 +59,17 @@ func IsUserAllowedToUpdate(pull *models.PullRequest, user *models.User) (bool, e
HeadBranch: pull.BaseBranch, HeadBranch: pull.BaseBranch,
BaseBranch: pull.HeadBranch, BaseBranch: pull.HeadBranch,
} }
err = pr.LoadProtectedBranch()
if err != nil {
return false, err
}
// Update function need push permission
if pr.ProtectedBranch != nil && !pr.ProtectedBranch.CanUserPush(user.ID) {
return false, nil
}
return IsUserAllowedToMerge(pr, headRepoPerm, user) return IsUserAllowedToMerge(pr, headRepoPerm, user)
} }