mews/captcha 验证码组件

发布时间 2023-11-02 14:50:44作者: yang10101
   /**
* 图像验证码
*/
public function captcha(CaptchaBridge $captcha, $type = 'default')
{
$api_captcha = $captcha->newInstance(ApiSessionStore::getSession());

$response = $api_captcha->create($type, true);
return $this->success($response);
  }
/**
* 图像验证
*/
public function captchaCheck(Request $request, CaptchaBridge $captcha, $type = 'default', $forget = false)
{
//调用captcha_api_check方法。
$captcha = $request->input('captcha'); //验证码
$key = $request->input('key'); //key

if (!captcha_api_check($captcha , $key)){
return $this->failed('验证码错误');
}else{
return $this->success('验证通过');
}

 }