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.

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