From 4a5c9ab1e6435bbf33e5657632fd3f09c0a0fca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Mon, 24 Apr 2017 00:00:42 +0200 Subject: [PATCH] FEATURE #1831: add recaptcha module --- composer.json | 3 +- composer.lock | 211 +++++++++++------- config/.gitignore | 1 + config/app.php | 2 + config/recaptcha.php | 66 ++++++ .../Http/Requests/SendNewEmailRequest.php | 7 +- .../admin/settings/parts/recaptcha.blade.php | 18 -- 7 files changed, 207 insertions(+), 101 deletions(-) create mode 100644 config/recaptcha.php delete mode 100644 resources/views/admin/settings/parts/recaptcha.blade.php diff --git a/composer.json b/composer.json index 67731974..8d81e4f2 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,8 @@ "mcamara/laravel-localization": "^1.1", "franzose/closure-table": "^4.1", "intervention/image": "^2.3", - "webwizo/laravel-shortcodes": "1.0.4" + "webwizo/laravel-shortcodes": "1.0.4", + "greggilbert/recaptcha": "^2.2@dev" }, "require-dev": { "fzaninotto/faker": "~1.4", diff --git a/composer.lock b/composer.lock index 72379f2f..8c49209e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "1d486fb23e76c7af1daf00bee207919c", - "content-hash": "957b49e5a2e691ad8dbc0e665a87d6c7", + "content-hash": "b986e3e1805bf5cb028c24818beeb9a4", "packages": [ { "name": "classpreloader/classpreloader", @@ -59,7 +58,7 @@ "class", "preload" ], - "time": "2016-01-24 12:28:38" + "time": "2016-01-24T12:28:38+00:00" }, { "name": "dnoegel/php-xdg-base-dir", @@ -92,7 +91,7 @@ "MIT" ], "description": "implementation of xdg base directory specification for php", - "time": "2014-10-24 07:27:01" + "time": "2014-10-24T07:27:01+00:00" }, { "name": "doctrine/annotations", @@ -160,7 +159,7 @@ "docblock", "parser" ], - "time": "2016-08-31 09:31:57" + "time": "2016-08-31T09:31:57+00:00" }, { "name": "doctrine/cache", @@ -229,7 +228,7 @@ "cache", "caching" ], - "time": "2016-07-15 15:57:08" + "time": "2016-07-15T15:57:08+00:00" }, { "name": "doctrine/collections", @@ -295,7 +294,7 @@ "collections", "iterator" ], - "time": "2016-09-01 10:39:08" + "time": "2016-09-01T10:39:08+00:00" }, { "name": "doctrine/common", @@ -368,7 +367,7 @@ "persistence", "spl" ], - "time": "2016-07-20 15:39:51" + "time": "2016-07-20T15:39:51+00:00" }, { "name": "doctrine/dbal", @@ -440,7 +439,7 @@ "persistence", "queryobject" ], - "time": "2016-08-25 23:11:10" + "time": "2016-08-25T23:11:10+00:00" }, { "name": "doctrine/inflector", @@ -507,7 +506,7 @@ "singularize", "string" ], - "time": "2016-05-12 17:23:41" + "time": "2016-05-12T17:23:41+00:00" }, { "name": "doctrine/lexer", @@ -561,7 +560,7 @@ "lexer", "parser" ], - "time": "2014-09-09 13:34:57" + "time": "2014-09-09T13:34:57+00:00" }, { "name": "erusev/parsedown", @@ -600,7 +599,7 @@ "markdown", "parser" ], - "time": "2015-10-04 16:44:32" + "time": "2015-10-04T16:44:32+00:00" }, { "name": "erusev/parsedown-extra", @@ -644,7 +643,7 @@ "parsedown", "parser" ], - "time": "2015-11-01 10:19:22" + "time": "2015-11-01T10:19:22+00:00" }, { "name": "franzose/closure-table", @@ -702,7 +701,59 @@ "laravel", "pages" ], - "time": "2016-07-08 08:19:46" + "time": "2016-07-08T08:19:46+00:00" + }, + { + "name": "greggilbert/recaptcha", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/greggilbert/recaptcha.git", + "reference": "298cbc072e8ba734df2b8af798f848dacd27a4c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/greggilbert/recaptcha/zipball/298cbc072e8ba734df2b8af798f848dacd27a4c9", + "reference": "298cbc072e8ba734df2b8af798f848dacd27a4c9", + "shasum": "" + }, + "require": { + "illuminate/support": "~5.1", + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/migrations" + ], + "psr-4": { + "Greggilbert\\Recaptcha\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Greg Gilbert", + "email": "greg@greg-gilbert.com" + } + ], + "description": "reCAPTCHA Validator for Laravel 5", + "homepage": "http://github.com/greggilbert/recaptcha", + "keywords": [ + "captcha", + "laravel", + "laravel5", + "recaptcha" + ], + "time": "2017-04-06 17:10:49" }, { "name": "guzzlehttp/psr7", @@ -872,7 +923,7 @@ "homepage": "http://www.acci.cz" } ], - "time": "2014-04-08 15:00:19" + "time": "2014-04-08T15:00:19+00:00" }, { "name": "jakub-onderka/php-console-highlighter", @@ -916,7 +967,7 @@ "homepage": "http://www.acci.cz/" } ], - "time": "2015-04-20 18:58:01" + "time": "2015-04-20T18:58:01+00:00" }, { "name": "jeremeamia/SuperClosure", @@ -974,7 +1025,7 @@ "serialize", "tokenizer" ], - "time": "2016-02-29 04:36:50" + "time": "2016-02-29T04:36:50+00:00" }, { "name": "laravel/framework", @@ -1104,7 +1155,7 @@ "framework", "laravel" ], - "time": "2016-08-26 16:26:18" + "time": "2016-08-26T16:26:18+00:00" }, { "name": "laravelcollective/html", @@ -1158,7 +1209,7 @@ ], "description": "HTML and Form Builders for the Laravel Framework", "homepage": "http://laravelcollective.com", - "time": "2016-07-12 14:16:43" + "time": "2016-07-12T14:16:43+00:00" }, { "name": "league/flysystem", @@ -1241,7 +1292,7 @@ "sftp", "storage" ], - "time": "2016-08-26 20:18:09" + "time": "2016-08-26T20:18:09+00:00" }, { "name": "mcamara/laravel-localization", @@ -1289,7 +1340,7 @@ "localization", "php" ], - "time": "2016-08-25 18:28:07" + "time": "2016-08-25T18:28:07+00:00" }, { "name": "monolog/monolog", @@ -1367,7 +1418,7 @@ "logging", "psr-3" ], - "time": "2016-07-29 03:23:52" + "time": "2016-07-29T03:23:52+00:00" }, { "name": "mtdowling/cron-expression", @@ -1411,7 +1462,7 @@ "cron", "schedule" ], - "time": "2016-01-26 21:23:30" + "time": "2016-01-26T21:23:30+00:00" }, { "name": "nesbot/carbon", @@ -1464,7 +1515,7 @@ "datetime", "time" ], - "time": "2016-07-22 14:20:35" + "time": "2016-07-22T14:20:35+00:00" }, { "name": "nikic/php-parser", @@ -1515,7 +1566,7 @@ "parser", "php" ], - "time": "2016-08-30 20:37:51" + "time": "2016-08-30T20:37:51+00:00" }, { "name": "paragonie/random_compat", @@ -1563,7 +1614,7 @@ "pseudorandom", "random" ], - "time": "2016-04-03 05:47:09" + "time": "2016-04-03T05:47:09+00:00" }, { "name": "pingpong/generators", @@ -1612,7 +1663,7 @@ "laravel", "pingpong" ], - "time": "2016-02-26 04:53:40" + "time": "2016-02-26T04:53:40+00:00" }, { "name": "pingpong/menus", @@ -1664,7 +1715,7 @@ "navigation", "pingpong" ], - "time": "2016-08-23 05:51:55" + "time": "2016-08-23T05:51:55+00:00" }, { "name": "pingpong/modules", @@ -1715,7 +1766,7 @@ "modules", "pingpong" ], - "time": "2016-01-29 04:39:40" + "time": "2016-01-29T04:39:40+00:00" }, { "name": "pingpong/support", @@ -1757,7 +1808,7 @@ } ], "description": "Support Component of Pingpong Sky Package", - "time": "2016-01-07 08:23:04" + "time": "2016-01-07T08:23:04+00:00" }, { "name": "psr/http-message", @@ -1854,7 +1905,7 @@ "psr", "psr-3" ], - "time": "2016-01-06 21:40:42" + "time": "2016-01-06T21:40:42+00:00" }, { "name": "psy/psysh", @@ -1926,7 +1977,7 @@ "interactive", "shell" ], - "time": "2016-03-09 05:03:14" + "time": "2016-03-09T05:03:14+00:00" }, { "name": "swiftmailer/swiftmailer", @@ -1979,7 +2030,7 @@ "mail", "mailer" ], - "time": "2016-08-19 20:47:22" + "time": "2016-08-19T20:47:22+00:00" }, { "name": "symfony/console", @@ -2039,7 +2090,7 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2016-07-30 07:22:48" + "time": "2016-07-30T07:22:48+00:00" }, { "name": "symfony/debug", @@ -2096,7 +2147,7 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2016-07-30 07:22:48" + "time": "2016-07-30T07:22:48+00:00" }, { "name": "symfony/event-dispatcher", @@ -2156,7 +2207,7 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2016-07-19 10:47:02" + "time": "2016-07-19T10:47:02+00:00" }, { "name": "symfony/finder", @@ -2205,7 +2256,7 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2016-06-29 05:40:00" + "time": "2016-06-29T05:40:00+00:00" }, { "name": "symfony/http-foundation", @@ -2258,7 +2309,7 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2016-07-17 13:54:30" + "time": "2016-07-17T13:54:30+00:00" }, { "name": "symfony/http-kernel", @@ -2340,7 +2391,7 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2016-07-30 09:29:03" + "time": "2016-07-30T09:29:03+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -2399,7 +2450,7 @@ "portable", "shim" ], - "time": "2016-08-30 17:06:17" + "time": "2016-08-30T17:06:17+00:00" }, { "name": "symfony/polyfill-php56", @@ -2455,7 +2506,7 @@ "portable", "shim" ], - "time": "2016-08-17 08:39:54" + "time": "2016-08-17T08:39:54+00:00" }, { "name": "symfony/polyfill-util", @@ -2507,7 +2558,7 @@ "polyfill", "shim" ], - "time": "2016-05-18 14:26:46" + "time": "2016-05-18T14:26:46+00:00" }, { "name": "symfony/process", @@ -2556,7 +2607,7 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2016-07-28 11:13:34" + "time": "2016-07-28T11:13:34+00:00" }, { "name": "symfony/routing", @@ -2631,7 +2682,7 @@ "uri", "url" ], - "time": "2016-06-29 05:40:00" + "time": "2016-06-29T05:40:00+00:00" }, { "name": "symfony/translation", @@ -2695,7 +2746,7 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2016-07-30 07:22:48" + "time": "2016-07-30T07:22:48+00:00" }, { "name": "symfony/var-dumper", @@ -2758,7 +2809,7 @@ "debug", "dump" ], - "time": "2016-07-26 08:03:56" + "time": "2016-07-26T08:03:56+00:00" }, { "name": "vlucas/phpdotenv", @@ -2808,7 +2859,7 @@ "env", "environment" ], - "time": "2016-09-01 10:05:43" + "time": "2016-09-01T10:05:43+00:00" }, { "name": "watson/sitemap", @@ -2854,7 +2905,7 @@ "laravel", "sitemaps" ], - "time": "2016-08-18 23:27:53" + "time": "2016-08-18T23:27:53+00:00" }, { "name": "webwizo/laravel-shortcodes", @@ -2915,7 +2966,7 @@ "shortcodes", "wordpress" ], - "time": "2016-08-25 06:02:46" + "time": "2016-08-25T06:02:46+00:00" } ], "packages-dev": [ @@ -2971,7 +3022,7 @@ "profiler", "webprofiler" ], - "time": "2016-08-25 20:55:54" + "time": "2016-08-25T20:55:54+00:00" }, { "name": "doctrine/instantiator", @@ -3025,7 +3076,7 @@ "constructor", "instantiate" ], - "time": "2016-03-31 10:24:22" + "time": "2016-03-31T10:24:22+00:00" }, { "name": "fzaninotto/faker", @@ -3075,7 +3126,7 @@ "faker", "fixtures" ], - "time": "2016-09-01 09:55:47" + "time": "2016-09-01T09:55:47+00:00" }, { "name": "hamcrest/hamcrest-php", @@ -3126,7 +3177,7 @@ "keywords": [ "test" ], - "time": "2016-01-19 12:08:55" + "time": "2016-01-19T12:08:55+00:00" }, { "name": "ignasbernotas/laravel-model-generator", @@ -3169,7 +3220,7 @@ "model", "schema" ], - "time": "2016-05-24 16:57:40" + "time": "2016-05-24T16:57:40+00:00" }, { "name": "maximebf/debugbar", @@ -3230,7 +3281,7 @@ "debug", "debugbar" ], - "time": "2016-08-28 15:57:48" + "time": "2016-08-28T15:57:48+00:00" }, { "name": "mockery/mockery", @@ -3295,7 +3346,7 @@ "test double", "testing" ], - "time": "2016-09-03 07:05:34" + "time": "2016-09-03T07:05:34+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -3349,7 +3400,7 @@ "reflection", "static analysis" ], - "time": "2015-12-27 11:43:31" + "time": "2015-12-27T11:43:31+00:00" }, { "name": "phpdocumentor/reflection-docblock", @@ -3394,7 +3445,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2016-06-10 09:48:41" + "time": "2016-06-10T09:48:41+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -3441,7 +3492,7 @@ "email": "me@mikevanriel.com" } ], - "time": "2016-06-10 07:14:17" + "time": "2016-06-10T07:14:17+00:00" }, { "name": "phpspec/prophecy", @@ -3503,7 +3554,7 @@ "spy", "stub" ], - "time": "2016-07-19 16:08:43" + "time": "2016-07-19T16:08:43+00:00" }, { "name": "phpunit/php-code-coverage", @@ -3565,7 +3616,7 @@ "testing", "xunit" ], - "time": "2015-10-06 15:47:00" + "time": "2015-10-06T15:47:00+00:00" }, { "name": "phpunit/php-file-iterator", @@ -3612,7 +3663,7 @@ "filesystem", "iterator" ], - "time": "2015-06-21 13:08:43" + "time": "2015-06-21T13:08:43+00:00" }, { "name": "phpunit/php-text-template", @@ -3653,7 +3704,7 @@ "keywords": [ "template" ], - "time": "2015-06-21 13:50:34" + "time": "2015-06-21T13:50:34+00:00" }, { "name": "phpunit/php-timer", @@ -3697,7 +3748,7 @@ "keywords": [ "timer" ], - "time": "2016-05-12 18:03:57" + "time": "2016-05-12T18:03:57+00:00" }, { "name": "phpunit/php-token-stream", @@ -3746,7 +3797,7 @@ "keywords": [ "tokenizer" ], - "time": "2015-09-23 14:46:55" + "time": "2015-09-23T14:46:55+00:00" }, { "name": "phpunit/phpunit", @@ -3818,7 +3869,7 @@ "testing", "xunit" ], - "time": "2016-08-28 06:58:45" + "time": "2016-08-28T06:58:45+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -3874,7 +3925,7 @@ "mock", "xunit" ], - "time": "2015-10-02 06:51:40" + "time": "2015-10-02T06:51:40+00:00" }, { "name": "sebastian/comparator", @@ -3938,7 +3989,7 @@ "compare", "equality" ], - "time": "2015-07-26 15:48:44" + "time": "2015-07-26T15:48:44+00:00" }, { "name": "sebastian/diff", @@ -3990,7 +4041,7 @@ "keywords": [ "diff" ], - "time": "2015-12-08 07:14:41" + "time": "2015-12-08T07:14:41+00:00" }, { "name": "sebastian/environment", @@ -4040,7 +4091,7 @@ "environment", "hhvm" ], - "time": "2016-08-18 05:49:44" + "time": "2016-08-18T05:49:44+00:00" }, { "name": "sebastian/exporter", @@ -4107,7 +4158,7 @@ "export", "exporter" ], - "time": "2016-06-17 09:04:28" + "time": "2016-06-17T09:04:28+00:00" }, { "name": "sebastian/global-state", @@ -4158,7 +4209,7 @@ "keywords": [ "global state" ], - "time": "2015-10-12 03:26:01" + "time": "2015-10-12T03:26:01+00:00" }, { "name": "sebastian/recursion-context", @@ -4211,7 +4262,7 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2016-01-28 05:39:29" + "time": "2016-01-28T05:39:29+00:00" }, { "name": "sebastian/version", @@ -4246,7 +4297,7 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2015-06-21 13:59:46" + "time": "2015-06-21T13:59:46+00:00" }, { "name": "symfony/css-selector", @@ -4299,7 +4350,7 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2016-06-29 05:40:00" + "time": "2016-06-29T05:40:00+00:00" }, { "name": "symfony/dom-crawler", @@ -4355,7 +4406,7 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "time": "2016-07-30 07:22:48" + "time": "2016-07-30T07:22:48+00:00" }, { "name": "symfony/yaml", @@ -4410,7 +4461,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-09-02 02:14:06" + "time": "2016-09-02T02:14:06+00:00" }, { "name": "webmozart/assert", @@ -4460,12 +4511,14 @@ "check", "validate" ], - "time": "2016-08-18 09:30:53" + "time": "2016-08-18T09:30:53+00:00" } ], "aliases": [], "minimum-stability": "dev", - "stability-flags": [], + "stability-flags": { + "greggilbert/recaptcha": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/config/.gitignore b/config/.gitignore index a6acbe5b..30f2be9f 100644 --- a/config/.gitignore +++ b/config/.gitignore @@ -19,3 +19,4 @@ !sitemap.php !image.php !view.php +!recaptcha.php \ No newline at end of file diff --git a/config/app.php b/config/app.php index 8655d7a1..c27f6e58 100644 --- a/config/app.php +++ b/config/app.php @@ -172,6 +172,7 @@ return [ App\Providers\RouteServiceProvider::class, App\Providers\BladeExtender::class, \App\Providers\TemplateServiceProvider::class, + \Greggilbert\Recaptcha\RecaptchaServiceProvider::class, ], /* @@ -221,6 +222,7 @@ return [ 'Validator' => Illuminate\Support\Facades\Validator::class, 'LaravelLocalization' => Mcamara\LaravelLocalization\Facades\LaravelLocalization::class, 'View' => Illuminate\Support\Facades\View::class, + 'Recaptcha' => Greggilbert\Recaptcha\Facades\Recaptcha::class, 'Shortcode' => Webwizo\Shortcodes\Facades\Shortcode::class, ], diff --git a/config/recaptcha.php b/config/recaptcha.php new file mode 100644 index 00000000..61957b81 --- /dev/null +++ b/config/recaptcha.php @@ -0,0 +1,66 @@ + env('RECAPTCHA_PUBLIC_KEY', ''), + 'private_key' => env('RECAPTCHA_PRIVATE_KEY', ''), + + /* + |-------------------------------------------------------------------------- + | Template + |-------------------------------------------------------------------------- + | + | Set a template to use if you don't want to use the standard one. + | + */ + 'template' => '', + + /* + |-------------------------------------------------------------------------- + | Driver + |-------------------------------------------------------------------------- + | + | Determine how to call out to get response; values are 'curl' or 'native'. + | Only applies to v2. + | + */ + 'driver' => 'curl', + + /* + |-------------------------------------------------------------------------- + | Options + |-------------------------------------------------------------------------- + | + | Various options for the driver + | + */ + 'options' => [ + + 'curl_timeout' => 1, + 'curl_verify' => true, + + ], + + /* + |-------------------------------------------------------------------------- + | Version + |-------------------------------------------------------------------------- + | + | Set which version of ReCaptcha to use. + | + */ + + 'version' => 2, + +]; diff --git a/modules/ContactForm/Http/Requests/SendNewEmailRequest.php b/modules/ContactForm/Http/Requests/SendNewEmailRequest.php index e1a84208..7e0dab6a 100644 --- a/modules/ContactForm/Http/Requests/SendNewEmailRequest.php +++ b/modules/ContactForm/Http/Requests/SendNewEmailRequest.php @@ -12,9 +12,10 @@ class SendNewEmailRequest extends Request public function rules() { return [ - 'name' => 'required', - 'email' => 'required|email', - 'message' => 'required', + 'name' => 'required', + 'email' => 'required|email', + 'message' => 'required', + 'g-recaptcha-response' => 'required|recaptcha', ]; } } diff --git a/resources/views/admin/settings/parts/recaptcha.blade.php b/resources/views/admin/settings/parts/recaptcha.blade.php deleted file mode 100644 index 95efc5ab..00000000 --- a/resources/views/admin/settings/parts/recaptcha.blade.php +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - -