You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1001 B

5 years ago
  1. # recaptcha-package
  2. the Public repo of the reCaptcha project.
  3. ## Installation
  4. Require the package:
  5. ```sh
  6. $ composer require dakyaco/ketabuzz
  7. ```
  8. Add these lines to ``config/services.php``
  9. ```sh
  10. 'recaptcha' => [
  11. 'url' => env('RECAPTCHA_URL'),
  12. 'secret' => env('RECAPTCHA_SECRET'),
  13. ]
  14. ```
  15. Now go to ``.env`` file and set your credentials
  16. ```sh
  17. RECAPTCHA_URL=
  18. RECAPTCHA_SECRET=your-secret-key
  19. ```
  20. ## How to use
  21. Go to ``app/Http/Controllers/LoginController.php`` and add following code
  22. (you can handle it whatever you want. It's just an option)
  23. ```sh
  24. use Dakyaco\Recaptcha\Facade\Recaptcha;
  25. use AuthenticatesUsers {
  26. validateLogin as validateCredentials;
  27. }
  28. // ....
  29. protected function validateLogin(Request $request)
  30. {
  31. $result = Recaptcha::verify($request);
  32. if($result['valid']) {
  33. $this->validateCredentials($request);
  34. } else {
  35. throw ValidationException::withMessages([
  36. 'recaptcha' => 'کپچا صحیح نمی باشد',
  37. ]);
  38. }
  39. }
  40. ```