public function beforeAction($action) { $_token = \yii::$app->request->post_get('token'); //判断token是否合法 $user_id = TokenService::getService()->getIdByToken($_token); if (is_int($user_id) && $user_id < 0) { exit(\common\helpers\JsonHelper::returnError($user_id)); } $_POST['data']['user_id'] = $user_id; return true; }
public function checkCode($mobile, $code) { $_param = $this->_paramMerge($mobile, $code); //请求接口 $_response = $this->postRequest($_param); //解析返回值 $_return = \common\helpers\JsonHelper::decode($_response); if (is_array($_return) && $_return['status'] == 200) { return true; } else { return false; } }