https://github.com/masasron/adonis-recaptcha
Display and verify Google's Recaptcha on Adoins.
https://github.com/masasron/adonis-recaptcha
adonisjs google javascript recaptcha recaptcha-api
Last synced: 2 months ago
JSON representation
Display and verify Google's Recaptcha on Adoins.
- Host: GitHub
- URL: https://github.com/masasron/adonis-recaptcha
- Owner: masasron
- License: mit
- Created: 2017-02-15T10:49:22.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-15T10:53:13.000Z (almost 9 years ago)
- Last Synced: 2025-07-19T03:36:29.418Z (5 months ago)
- Topics: adonisjs, google, javascript, recaptcha, recaptcha-api
- Language: JavaScript
- Size: 825 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Adonis Recaptcha
### Installation
To get the latest version of Adonis Recaptcha, simply run
```
npm install adonis-recaptcha --save
```
Once Adonis Recaptcha is installed, you need to register the service provider.
Open up bootstrap/app.js and add the following to the providers key.
```js
// bootstrap/app.js
const providers = [
...,
'adonis-recaptcha/providers/RecaptchaProvider',
]
```
You can register the Recaptcha facade in the aliases key of your bootstrap/app.js file if you like.
```js
// bootstrap/app.js
const aliases = {
...,
Recaptcha: 'Adonis/Addons/Recaptcha'
}
```
Enable the recaptcha middleware inside `app/Http/kernel.js` file.
```js
// app/Http/kernel.js
const namedMiddleware = {
...,
recaptcha: 'Adonis/Middleware/Recaptcha'
}
```
Add your site key and secret to your .env file using the following keys:
```
RECAPTCHA_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
RECAPTCHA_SITE_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```
(keys can be generated here https://www.google.com/recaptcha/admin)
### Usage
#### Middleware
Use the recaptcha middleware to require catpcha solution for a given route.
```js
Route.post('register','GuestController.register').middleware('recaptcha')
```
#### Display Recaptcha Widget
```html
{% set recaptcha = use('Recaptcha') %}
{{ recaptcha.script | safe }}
{{ recaptcha.field | safe }}
Submit
```