diff --git a/frontend/controllers/CommonController.php b/frontend/controllers/CommonController.php index 3d8ba01..4eacfe6 100644 --- a/frontend/controllers/CommonController.php +++ b/frontend/controllers/CommonController.php @@ -25,6 +25,7 @@ class CommonController extends \yii\web\Controller public $my = null; public $web = null; public $enableCsrfValidation = false; + public $layout = 'blue-main'; public function init() { @@ -237,6 +238,7 @@ class CommonController extends \yii\web\Controller $request = Yii::$app->request; $result = array(); $result['success'] = false; + $result['msg'] = '更改失败'; if($request->isPost){ $user_id = $request->post('id'); @@ -260,20 +262,19 @@ class CommonController extends \yii\web\Controller if($user!= '' && $user_pwd != '') { $user->salt = MyLib::randomStr(4); $user->password = MyLib::hashPwd($user_pwd,$user->salt); - $user_res = $user->save(); - if(!$user_res){ - throw new \Exception('操作失败!'); + if(!$user->save()) { + throw new \Exception(print_r($user->getErrors(), true)); } $result['success'] = true; $result['msg'] = '保存成功'; - $tran->commit(); } + $tran->commit(); }catch(\Exception $e){ $tran->rollBack(); - throw $e; + $result['msg'] = $e->getMessage(); } - return $result; } + return $result; } public function actionLeft() diff --git a/frontend/views/common/login.php b/frontend/views/common/login.php index b7c47a8..b74cc42 100644 --- a/frontend/views/common/login.php +++ b/frontend/views/common/login.php @@ -30,7 +30,7 @@