Skip to content

Commit f4a69c8

Browse files
author
Gusted
committed
Return error + add check for new issues
1 parent 443517c commit f4a69c8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

routers/web/repo/issue.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,8 @@ func NewIssue(ctx *context.Context) {
803803
body := ctx.FormString("body")
804804
ctx.Data["BodyQuery"] = body
805805

806-
ctx.Data["IsProjectsEnabled"] = ctx.Repo.CanRead(unit.TypeProjects)
806+
isProjectsEnabled := ctx.Repo.CanRead(unit.TypeProjects)
807+
ctx.Data["IsProjectsEnabled"] = isProjectsEnabled
807808
ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled
808809
upload.AddUploadContext(ctx, "comment")
809810

@@ -819,7 +820,7 @@ func NewIssue(ctx *context.Context) {
819820
}
820821

821822
projectID := ctx.FormInt64("project")
822-
if projectID > 0 {
823+
if projectID > 0 && isProjectsEnabled {
823824
project, err := project_model.GetProjectByID(ctx, projectID)
824825
if err != nil {
825826
log.Error("GetProjectByID: %d: %v", projectID, err)
@@ -1042,8 +1043,12 @@ func NewIssuePost(ctx *context.Context) {
10421043
return
10431044
}
10441045

1045-
// User must also be able to see the project.
1046-
if projectID > 0 && ctx.Repo.CanRead(unit.TypeProjects) {
1046+
if projectID > 0 {
1047+
if !ctx.Repo.CanRead(unit.TypeProjects) {
1048+
// User must also be able to see the project.
1049+
ctx.Error(http.StatusBadRequest, "user hasn't permissions to read projects")
1050+
return
1051+
}
10471052
if err := issues_model.ChangeProjectAssign(issue, ctx.Doer, projectID); err != nil {
10481053
ctx.ServerError("ChangeProjectAssign", err)
10491054
return

0 commit comments

Comments
 (0)