注册接口调试

webUi^2
zhaocheng 5 years ago
parent 6259aed759
commit 8c6babbb9e
  1. 9
      frontend/controllers/ApiController.php

@ -873,8 +873,7 @@ class ApiController extends \yii\web\Controller
if (isset($ret['code']) && $ret['code'] == 200) { if (isset($ret['code']) && $ret['code'] == 200) {
$result['code'] = 0; $result['code'] = 0;
$result['msg'] = '短信发送成功'; $result['msg'] = '短信发送成功';
$session = Yii::$app->session; Yii::$app->cache->set('hy_vcode_'.$params['mobile'], $code);
$session->set('hy_vcode_'.$params['mobile'], $code);
} else { } else {
$result['success'] = false; $result['success'] = false;
$result['msg'] = $ret['msg']; $result['msg'] = $ret['msg'];
@ -905,9 +904,9 @@ class ApiController extends \yii\web\Controller
$result['msg'] = '参数错误'; $result['msg'] = '参数错误';
return $result; return $result;
} }
if($code == '' || Yii::$app->session->get('hy_vcode_'.$mobile) != $code){ if($code == '' || Yii::$app->cache->get('hy_vcode_'.$mobile) != $code){
$result['code'] = -1; $result['code'] = -1;
$result['msg'] = '验证码错误'; $result['msg'] = '验证码错误,系统保存为'.Yii::$app->cache->get('hy_vcode_'.$mobile);
return $result; return $result;
} }
if($user) { if($user) {
@ -969,7 +968,7 @@ class ApiController extends \yii\web\Controller
$result['code'] = -1; $result['code'] = -1;
$result['msg'] = $e->getMessage(); $result['msg'] = $e->getMessage();
} }
Yii::$app->session->remove('hy_vcode_'.$mobile); Yii::$app->cache->remove('hy_vcode_'.$mobile);
} }
return $result; return $result;
} }

Loading…
Cancel
Save