From f890fdc2d30f3a285fb950b33156dd8b6deb64ee Mon Sep 17 00:00:00 2001 From: Guillermo Giuliana Date: Tue, 29 Mar 2022 13:48:46 -0300 Subject: [PATCH] [DEV-161] Add apikey to ticket comment path (#1173) * update ticket comment path * update validations * remove useless line --- server/controllers/ticket/comment.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/server/controllers/ticket/comment.php b/server/controllers/ticket/comment.php index 9a70527a..f8f73633 100755 --- a/server/controllers/ticket/comment.php +++ b/server/controllers/ticket/comment.php @@ -42,8 +42,7 @@ class CommentController extends Controller { private $imagePaths; public function validations() { - $this->session = Session::getInstance(); - return [ + $validations = [ 'permission' => 'user', 'requestData' => [ 'content' => [ @@ -56,6 +55,15 @@ class CommentController extends Controller { ] ] ]; + if(Controller::request('captcha')){ + $validations['permission'] = 'any'; + $validations['requestData']['captcha'] = [ + 'validation' => DataValidator::captcha(APIKey::TICKET_CREATE_PERMISSION), + 'error' => ERRORS::INVALID_CAPTCHA + ]; + } + + return $validations; } public function handler() {