驗證碼使用(egg)
阿新 • • 發佈:2019-01-01
import { Service } from 'webrail'; import {captcha} from '@webrail/captcha'; let text:string; export class CaptchaService extends Service { public async create(){ let createSvg=new captcha().getCaptcha({ ignoreChars:'o0ilI1', noise:2, width:100, height:30, fontSize:37 }); text=createSvg.text.toUpperCase(); console.log('3',createSvg.text.toUpperCase()); console.log(text); return createSvg.data; } public async validate(captchaText:string){ console.log('1',text); console.log('2',captchaText); if(captchaText===text){ return true; }else{ return false; } } } export default CaptchaService;