| @@ -9,9 +9,8 @@ | ||
| 9 | 9 | class HandleSlackEvent |
| 10 | 10 | { |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * handleEvent method is responsible for handling slack events | |
| 14 | 13 | * @param string $token |
| 15 | 14 | * @return bool |
| 16 | 15 | * @throws Exception |
| 17 | 16 | */ |
| @@ -22,12 +21,8 @@ | ||
| 22 | 21 | $this->validateToken($token); |
| 23 | 22 | |
| 24 | 23 | $request = App::getInstance('request'); |
| 25 | 24 | |
| 26 | - if ($request->get('type') == 'url_verification') { | |
| 27 | - echo wp_kses_post($request->get('challenge')); | |
| 28 | - } | |
| 29 | - | |
| 30 | 25 | return (new SlackNotification())->processSlackEvent($request->get('event')); |
| 31 | 26 | } |
| 32 | 27 | |
| 33 | 28 | |
| @@ -32,11 +27,10 @@ | ||
| 32 | 27 | |
| 33 | 28 | |
| 34 | 29 | |
| 35 | 30 | /** |
| 36 | - * verifyProVersion method will check if the pro version is installed or not | |
| 37 | 31 | * @throws Exception |
| 38 | - * @return boolean | Exception | |
| 32 | + * @return bool | |
| 39 | 33 | */ |
| 40 | 34 | private function verifyProVersion () |
| 41 | 35 | { |
| 42 | 36 | if (!defined('FLUENTSUPPORTPRO')) { |
| @@ -46,17 +40,16 @@ | ||
| 46 | 40 | return true; |
| 47 | 41 | } |
| 48 | 42 | |
| 49 | 43 | /** |
| 50 | - * validateToken method will check if the token is valid or not | |
| 51 | 44 | * @param string $token |
| 52 | 45 | * @throws Exception |
| 53 | - * @return boolean | Exception | |
| 46 | + * @return bool | |
| 54 | 47 | */ |
| 55 | 48 | private function validateToken ($token) |
| 56 | 49 | { |
| 57 | - if (\FluentSupportPro\App\Services\Integrations\Slack\SlackHelper::getWebhookToken() != $token) { | |
| 58 | - throw new \Exception('Bot Token could not be verified', 404); | |
| 50 | + if (!hash_equals(\FluentSupportPro\App\Services\Integrations\Slack\SlackHelper::getWebhookToken(), $token)) { | |
| 51 | + throw new \Exception('Bot Token could not be verified', 403); | |
| 59 | 52 | } |
| 60 | 53 | return true; |
| 61 | 54 | } |
| 62 | 55 | } |