Browse Source

Update README.md

dev
Amir Reza Mehrbakhsh 5 years ago
parent
commit
551ffb41b5
2 changed files with 51 additions and 3 deletions
  1. +50
    -1
      README.md
  2. +1
    -2
      src/Recaptcha.php

+ 50
- 1
README.md View File

@ -1,3 +1,52 @@
# recaptcha-package # recaptcha-package
the Public repo of the reCaptcha project.
the Public repo of the reCaptcha project.
## Installation
Require the package:
```sh
$ composer require dakyaco/ketabuzz
```
Add these lines to ``config/services.php``
```sh
'recaptcha' => [
'url' => env('RECAPTCHA_URL'),
'secret' => env('RECAPTCHA_SECRET'),
]
```
Now go to ``.env`` file and set your credentials
```sh
RECAPTCHA_URL=
RECAPTCHA_SECRET=your-secret-key
```
## How to use
Go to ``app/Http/Controllers/LoginController.php`` and add following code
(you can handle it whatever you want. It's just an option)
```sh
use Dakyaco\Recaptcha\Facade\Recaptcha;
use AuthenticatesUsers {
validateLogin as validateCredentials;
}
// ....
protected function validateLogin(Request $request)
{
$result = Recaptcha::verify($request);
if($result['valid']) {
$this->validateCredentials($request);
} else {
throw ValidationException::withMessages([
'recaptcha' => 'کپچا صحیح نمی باشد',
]);
}
}
```

+ 1
- 2
src/Recaptcha.php View File

@ -24,8 +24,7 @@ class Recaptcha {
'p-captcha-session' => $session, 'p-captcha-session' => $session,
'sitekey' => $this->secretKey 'sitekey' => $this->secretKey
]; ];
// TODO: document this:
// add keys to config/services.php
$result = $this->call('POST', $this->url, $data); $result = $this->call('POST', $this->url, $data);
$result = json_decode($result, true); $result = json_decode($result, true);
return $result; return $result;


Loading…
Cancel
Save