Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Aug 11, 2023
1 parent d7cafcd commit 40ea174
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

(new Extend\Frontend('admin'))
->js(__DIR__.'/js/dist/admin.js')
->css(__DIR__ . '/resources/less/admin.less'),
->css(__DIR__.'/resources/less/admin.less'),

new Extend\Locales(__DIR__.'/resources/locale'),

Expand Down
9 changes: 9 additions & 0 deletions src/Api/Controller/TestReCaptchaController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of fof/recaptcha.
*
* Copyright (c) FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FoF\ReCaptcha\Api\Controller;

use Flarum\Http\RequestUtil;
Expand Down
11 changes: 6 additions & 5 deletions src/Listeners/AddValidatorRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
use FoF\ReCaptcha\ReCaptcha\GuzzleRequestMethod;
use Illuminate\Validation\Validator;
use ReCaptcha\ReCaptcha;
use ReCaptcha\RequestMethod\CurlPost;
use ReCaptcha\RequestMethod\Post;

class AddValidatorRule
{
Expand All @@ -43,13 +41,16 @@ public function __invoke(AbstractValidator $flarumValidator, Validator $validato
$validator->addExtension(
'recaptcha',
function ($attribute, $value, $parameters) use ($validator, $secret) {
if (empty($value)) return false;
if (empty($value)) {
return false;
}

$verification = (new ReCaptcha($secret, new GuzzleRequestMethod('https://www.recaptcha.net/recaptcha/api/siteverify')))->verify($value);

if (!empty($verification->getErrorCodes())) {
$validator->setCustomMessages([
'recaptcha' => resolve('translator')->trans('validation.recaptcha-unknown', ['errors' => implode(', ', $verification->getErrorCodes())])]
$validator->setCustomMessages(
[
'recaptcha' => resolve('translator')->trans('validation.recaptcha-unknown', ['errors' => implode(', ', $verification->getErrorCodes())])]
);
}

Expand Down
9 changes: 9 additions & 0 deletions src/ReCaptcha/GuzzleRequestMethod.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of fof/recaptcha.
*
* Copyright (c) FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FoF\ReCaptcha\ReCaptcha;

use GuzzleHttp\Client;
Expand Down

0 comments on commit 40ea174

Please sign in to comment.