/** * @return string|\yii\web\Response 用户登录 */ public function actionLogin() { $model = new UserForm(); if ($model->load(Yii::$app->request->post(), '')) { if ($model->login()) { //查询未读消息 echo "login success"; } else { return "login failure"; } } }
public function actionLogin() { $model = new UserForm(); if ($model->load(Yii::$app->request->post())) { if ($model->validate()) { //验证通过,执行用户登录 if ($model->login()) { return $this->redirect(['admin/index/index', array('#1/2')]); } else { return $this->render('login', ['model' => $model]); } } } return $this->render('login', ['model' => $model]); }