@@ -803,7 +803,8 @@ func NewIssue(ctx *context.Context) {
803
803
body := ctx .FormString ("body" )
804
804
ctx .Data ["BodyQuery" ] = body
805
805
806
- ctx .Data ["IsProjectsEnabled" ] = ctx .Repo .CanRead (unit .TypeProjects )
806
+ isProjectsEnabled := ctx .Repo .CanRead (unit .TypeProjects )
807
+ ctx .Data ["IsProjectsEnabled" ] = isProjectsEnabled
807
808
ctx .Data ["IsAttachmentEnabled" ] = setting .Attachment .Enabled
808
809
upload .AddUploadContext (ctx , "comment" )
809
810
@@ -819,7 +820,7 @@ func NewIssue(ctx *context.Context) {
819
820
}
820
821
821
822
projectID := ctx .FormInt64 ("project" )
822
- if projectID > 0 {
823
+ if projectID > 0 && isProjectsEnabled {
823
824
project , err := project_model .GetProjectByID (ctx , projectID )
824
825
if err != nil {
825
826
log .Error ("GetProjectByID: %d: %v" , projectID , err )
@@ -1042,8 +1043,12 @@ func NewIssuePost(ctx *context.Context) {
1042
1043
return
1043
1044
}
1044
1045
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
+ }
1047
1052
if err := issues_model .ChangeProjectAssign (issue , ctx .Doer , projectID ); err != nil {
1048
1053
ctx .ServerError ("ChangeProjectAssign" , err )
1049
1054
return
0 commit comments