egg-trek-captcha

1.1.4 • Public • Published

egg-trek-captcha

A captcha plugin based on trek-captcha.

Install

npm i egg-trek-captcha --save

Usage

// {app_root}/config/plugin.js
exports.trekCaptcha = {
  enable: true,
  package: 'egg-trek-captcha',
};

Configuration

// {app_root}/config/config.default.js
exports.trekCaptcha = {
  // trek-captcha options
  size: 4,
  style: -1
  // redis related function (need egg-redis)
  redis: false,
  // captcha expires
  expires: 3000,
};

If you enable the redis related function, you can use "app.catpcha.verfiy" to verify your code.

Request should have an UUID and verify your code like this:

const res = await app.captcha.verify(uuid, code);
console.log(res);
/**
 * res: {
 *   success: true, // or false
 *   reason: '', // if failed, here's the reason
 * }
*/

License

MIT

Package Sidebar

Install

npm i egg-trek-captcha

Weekly Downloads

2

Version

1.1.4

License

MIT

Unpacked Size

5.25 kB

Total Files

11

Last publish

Collaborators

  • backrunner