0.2.4 • Published 12 months ago

adonisjs-hcaptcha v0.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

github-actions-image npm-image license-image synk-image

# npm
npm i adonisjs-hcaptcha
node ace configure adonisjs-hcaptcha

# yarn
yarn add adonisjs-hcaptcha
node ace configure adonisjs-hcaptcha

Signup for a account on hCaptcha website Login and follow the steps to get your secret and site key

HCAPTCHA_SECRET_KEY=YOUR_SECRET_KEY 
HCAPTCHA_SITE_KEY=YOUR_SITE_KEY
import Env from '@ioc:Adonis/Core/Env'

export default Env.rules({
  // ....
  HCAPTCHA_SITE_KEY: Env.schema.string(),
  HCAPTCHA_SECRET_KEY: Env.schema.string(),
})
Server.middleware.registerNamed({
  // ....
  hcaptcha: () => import('App/Middleware/Hcaptcha'),
})
Route.post('login', 'UserController.login').middleware('hcaptcha')

The new middleware will check for h-captcha-response field in request input

h-captcha-response field will contain the unique one time non repeating token which will be validated with hCaptcha to make sure its not a bot

export default class UsersController {
  public async index({ hcaptcha }: HttpContextContract) {
    if (hcaptcha.success) {
      // Do some action
    }
    // Throw error
  }
}
0.2.4

12 months ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago