errorHandler->error); } /** * Displays the login page */ public function actionLogin() { $model=new LoginForm; if (isset($_POST['username'])) { $model->attributes=$_POST; if($model->validate() && $model->login()){ Helper::ok(['token' => \Yii::app()->session->getSessionID(), 'refreshToken' => '']); } else { Helper::error('登入失败'); } } Helper::error('参数错误'); } /** * 发送验证码 */ public function actionSendCode() { $phone = Helper::getPostString('phone', ''); if (!Helper::isPhone($phone)) { Helper::error('手机号码格式错误'); } // 验证码发送限制 Helper::dealCommonResult(Helper::limitSmsSend(10, $phone, 5), false); if (!DB::getScalerWithCriteria('useradmin', DbCriteria::simpleCompare(['phone' => $phone])->setSelect('id'))) { Helper::error('该手机号用户不存在'); } $code = (string)random_int(100000,999999); RedisInstance::getInstance()->set('user_code:'.$phone, $code, 600); // 发送短信 Helper::dealCommonResult(SMS::getInstance()->send($phone, '2094847', [$code])); } /** * 找回密码 */ public function actionSetPassword() { $phone = Helper::getPostString('phone'); $code = Helper::getPostString('code'); $password = Helper::getPostString('password'); if (!Helper::isPhone($phone)) { Helper::error('手机号码格式错误'); } if (!$code || !$password) { Helper::error('参数错误'); } if (RedisInstance::getInstance()->get('user_code:'.$phone) != $code) { Helper::error('验证码错误'); } $id = DB::getScalerWithCriteria('useradmin', DbCriteria::simpleCompare(['phone' => $phone])->setSelect('id')); if (!$id) { Helper::error('该手机号用户不存在'); } DB::updateById('useradmin', ['password' => md5($password)], $id); Helper::ok(); } /******************************* 测试相关代码 ***************************************/ public function actionPhp() { (new DBTable(Helper::getGetString('t1')))->echoEditHtml(); } public function actionTs() { echo (new DBTable(Helper::getGetString('t1')))->getTsInterFace(); } public function actionForm() { (new DBTable(Helper::getGetString('t1')))->editVue(); } public function actionTable() { echo (new DBTable(Helper::getGetString('t1')))->getTableHtml(); } public function actionInfo() { echo (new DBTable(Helper::getGetString('t1')))->getDetailHtml(); } }