Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
e27a303a
Commit
e27a303a
authored
Apr 23, 2017
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mvc: merge API fixes as suggested by @adschellevis
parent
294b6137
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
15 deletions
+17
-15
ApiControllerBase.php
...e/mvc/app/controllers/OPNsense/Base/ApiControllerBase.php
+17
-15
No files found.
src/opnsense/mvc/app/controllers/OPNsense/Base/ApiControllerBase.php
View file @
e27a303a
...
@@ -137,23 +137,23 @@ class ApiControllerBase extends ControllerRoot
...
@@ -137,23 +137,23 @@ class ApiControllerBase extends ControllerRoot
$req_c
=
$object_info
->
getMethod
(
$callMethodName
)
->
getNumberOfRequiredParameters
();
$req_c
=
$object_info
->
getMethod
(
$callMethodName
)
->
getNumberOfRequiredParameters
();
if
(
$req_c
>
count
(
$dispatcher
->
getParams
()))
{
if
(
$req_c
>
count
(
$dispatcher
->
getParams
()))
{
$dispatchError
=
'action '
.
$dispatcher
->
getActionName
()
.
$dispatchError
=
'action '
.
$dispatcher
->
getActionName
()
.
' expects at least '
.
$req_c
.
' parameter(s)'
;
' expects at least '
.
$req_c
.
' parameter(s)'
;
}
else
{
// if body is send as json data, parse to $_POST first
$dispatchError
=
$this
->
parseJsonBodyData
();
}
if
(
$dispatchError
!=
null
)
{
// send error to client
$this
->
response
->
setStatusCode
(
400
,
"Bad Request"
);
$this
->
response
->
setContentType
(
'application/json'
,
'UTF-8'
);
$this
->
response
->
setJsonContent
(
array
(
'message'
=>
$dispatchError
,
'status'
=>
400
)
);
$this
->
response
->
send
();
return
false
;
}
}
}
}
// if body is send as json data, parse to $_POST first
$dispatchError
=
empty
(
$dispatchError
)
?
$this
->
parseJsonBodyData
()
:
$dispatchError
;
if
(
$dispatchError
!=
null
)
{
// send error to client
$this
->
response
->
setStatusCode
(
400
,
"Bad Request"
);
$this
->
response
->
setContentType
(
'application/json'
,
'UTF-8'
);
$this
->
response
->
setJsonContent
(
array
(
'message'
=>
$dispatchError
,
'status'
=>
400
)
);
$this
->
response
->
send
();
return
false
;
}
return
true
;
return
true
;
}
}
...
@@ -192,6 +192,8 @@ class ApiControllerBase extends ControllerRoot
...
@@ -192,6 +192,8 @@ class ApiControllerBase extends ControllerRoot
$this
->
response
->
setStatusCode
(
403
,
"Forbidden"
);
$this
->
response
->
setStatusCode
(
403
,
"Forbidden"
);
return
false
;
return
false
;
}
}
// when request is using a json body (based on content type), parse it first
$this
->
parseJsonBodyData
();
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment