Skip to content

Commit 6993bbe

Browse files
committed
fix
1 parent ed67149 commit 6993bbe

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

models/issues/issue_project.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func IssueAssignOrRemoveProject(ctx context.Context, issue *Issue, doer *user_mo
113113
}
114114
newColumnID = newDefaultColumn.ID
115115
}
116-
if !newProject.CanBeAccessedByOwnerRepo(issue.Repo.OwnerID, issue.Repo.ID) {
116+
if !newProject.CanBeAccessedByOwnerRepo(issue.Repo.OwnerID, issue.Repo) {
117117
return util.NewPermissionDeniedErrorf("issue %d can't be accessed by project %d", issue.ID, newProject.ID)
118118
}
119119
}

models/project/project.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ func (p *Project) IsRepositoryProject() bool {
161161
return p.Type == TypeRepository
162162
}
163163

164-
func (p *Project) CanBeAccessedByOwnerRepo(ownerID, repoID int64) bool {
164+
func (p *Project) CanBeAccessedByOwnerRepo(ownerID int64, repo *repo_model.Repository) bool {
165165
if p.Type == TypeRepository {
166-
return p.RepoID == repoID // if a project belongs to a repository, then its OwnerID is 0 and can be ignored
166+
return repo != nil && p.RepoID == repo.ID // if a project belongs to a repository, then its OwnerID is 0 and can be ignored
167167
}
168168
return p.OwnerID == ownerID && p.RepoID == 0
169169
}

routers/web/shared/project/column.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@ func MoveColumns(ctx *context.Context) {
1616
ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err)
1717
return
1818
}
19-
if project.OwnerID > 0 && project.OwnerID != ctx.ContextUser.ID {
20-
ctx.NotFound("InvalidOwnerID", nil)
21-
return
22-
}
23-
if project.RepoID > 0 && project.RepoID != ctx.Repo.Repository.ID {
24-
ctx.NotFound("InvalidRepoID", nil)
19+
if !project.CanBeAccessedByOwnerRepo(ctx.ContextUser.ID, ctx.Repo.Repository) {
20+
ctx.NotFound("CanBeAccessedByOwnerRepo", nil)
2521
return
2622
}
2723

0 commit comments

Comments
 (0)