Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed May 6, 2024
1 parent ed67149 commit 6993bbe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion models/issues/issue_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func IssueAssignOrRemoveProject(ctx context.Context, issue *Issue, doer *user_mo
}
newColumnID = newDefaultColumn.ID
}
if !newProject.CanBeAccessedByOwnerRepo(issue.Repo.OwnerID, issue.Repo.ID) {
if !newProject.CanBeAccessedByOwnerRepo(issue.Repo.OwnerID, issue.Repo) {
return util.NewPermissionDeniedErrorf("issue %d can't be accessed by project %d", issue.ID, newProject.ID)
}
}
Expand Down
4 changes: 2 additions & 2 deletions models/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ func (p *Project) IsRepositoryProject() bool {
return p.Type == TypeRepository
}

func (p *Project) CanBeAccessedByOwnerRepo(ownerID, repoID int64) bool {
func (p *Project) CanBeAccessedByOwnerRepo(ownerID int64, repo *repo_model.Repository) bool {
if p.Type == TypeRepository {
return p.RepoID == repoID // if a project belongs to a repository, then its OwnerID is 0 and can be ignored
return repo != nil && p.RepoID == repo.ID // if a project belongs to a repository, then its OwnerID is 0 and can be ignored
}
return p.OwnerID == ownerID && p.RepoID == 0
}
Expand Down
8 changes: 2 additions & 6 deletions routers/web/shared/project/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@ func MoveColumns(ctx *context.Context) {
ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err)
return
}
if project.OwnerID > 0 && project.OwnerID != ctx.ContextUser.ID {
ctx.NotFound("InvalidOwnerID", nil)
return
}
if project.RepoID > 0 && project.RepoID != ctx.Repo.Repository.ID {
ctx.NotFound("InvalidRepoID", nil)
if !project.CanBeAccessedByOwnerRepo(ctx.ContextUser.ID, ctx.Repo.Repository) {
ctx.NotFound("CanBeAccessedByOwnerRepo", nil)
return
}

Expand Down

0 comments on commit 6993bbe

Please sign in to comment.