diff --git a/app/application/.env.example b/app/application/.env.example index 61089d6..d32953a 100644 --- a/app/application/.env.example +++ b/app/application/.env.example @@ -5,6 +5,7 @@ APP_DEBUG=true APP_TIMEZONE=UTC APP_URL=http://localhost +APP_CAPTCHA=false CAPTCHA_API_DOMAIN=http://your-domain-captcha-or-IP:8081 CAPTCHA_PRIVATE_TOKEN= CAPTCHA_STATIC_PATH=http://your-domain-captcha-or-IP:8081/captcha diff --git a/app/application/app/Http/Controllers/AuthController.php b/app/application/app/Http/Controllers/AuthController.php index 6f13fea..d10b9d9 100644 --- a/app/application/app/Http/Controllers/AuthController.php +++ b/app/application/app/Http/Controllers/AuthController.php @@ -19,7 +19,9 @@ public function __construct( public function login(): View { - return view('login'); + return view('login', [ + 'captcha' => config('app.captcha', false), + ]); } public function authorization(AuthorizationRequest $request): RedirectResponse diff --git a/app/application/app/Http/Requests/AuthorizationRequest.php b/app/application/app/Http/Requests/AuthorizationRequest.php index 934d9c8..c9970fd 100644 --- a/app/application/app/Http/Requests/AuthorizationRequest.php +++ b/app/application/app/Http/Requests/AuthorizationRequest.php @@ -13,12 +13,17 @@ final class AuthorizationRequest extends FormRequest implements FormRequestDto */ public function rules(): array { - return [ + $rules = [ 'email' => ['required', 'email', 'max:255'], 'password' => ['required', 'min:3'], - 'captcha-verified' => ['captcha'], 'remember' => ['nullable', 'boolean'], ]; + + if (config('app.captcha', false)) { + $rules['captcha-verified'] = ['captcha']; + } + + return $rules; } public function getDto(): Authorization diff --git a/app/application/app/Http/Requests/Site/Feedback/SendRequest.php b/app/application/app/Http/Requests/Site/Feedback/SendRequest.php index befefb6..c873cee 100644 --- a/app/application/app/Http/Requests/Site/Feedback/SendRequest.php +++ b/app/application/app/Http/Requests/Site/Feedback/SendRequest.php @@ -32,12 +32,17 @@ public function attributes(): array */ public function rules(): array { - return [ + $rules = [ 'name' => ['nullable', 'string', 'max:255'], 'email' => ['nullable', 'string', 'max:255', 'email'], 'message' => ['required', 'string', 'max:5000'], - 'captcha-verified' => ['captcha'], ]; + + if (config('app.captcha', false)) { + $rules['captcha-verified'] = ['captcha']; + } + + return $rules; } public function getDto(): Send diff --git a/app/application/config/app.php b/app/application/config/app.php index 4f08f4e..683f309 100644 --- a/app/application/config/app.php +++ b/app/application/config/app.php @@ -28,6 +28,15 @@ 'env' => env('APP_ENV', 'production'), + /* + |-------------------------------------------------------------------------- + | Сaptcha + |-------------------------------------------------------------------------- + | + | Enables or disables captcha. + */ + 'captcha' => (bool) env('APP_CAPTCHA', false), + /* |-------------------------------------------------------------------------- | Application Debug Mode diff --git a/app/application/resources/views/login.blade.php b/app/application/resources/views/login.blade.php index 59e6483..f61034d 100644 --- a/app/application/resources/views/login.blade.php +++ b/app/application/resources/views/login.blade.php @@ -49,9 +49,11 @@ -