12345678910111213141516171819202122232425262728293031323334 |
- 'use strict';
- const Service = require('egg').Service;
- const svgCaptcha = require('svg-captcha');
- class CaptchaService extends Service {
-
- get(options = {}) {
- let defaults = {fontSize:50,color:false,noise:2,width:100,height:25};
- const captcha = svgCaptcha.createMathExpr(Object.assign(defaults,options));
- return captcha;
- }
-
- validate(text,session_text) {
- return text == session_text;
- }
- }
- module.exports = CaptchaService;
|