Example #1
0
 /**
  * 用户登录系统
  * @return Ambigous <\yii\web\Response, \yii\web\static, \yii\web\Response>|Ambigous <string, string>
  */
 public function actionLogin()
 {
     $modelf = new UserForm();
     $modelf->scenario = 'login';
     if ($modelf->load(Yii::$app->request->post(), '') && $modelf->validate()) {
         Yii::$app->getUser()->login($modelf->getUser(), $modelf->rememberMe ? 3600 * 24 * 30 : 0);
         return $this->renderContent(json_encode(array('success' => true)));
     } else {
         return $this->renderContent(json_encode(array('code' => 102, 'message' => '用户名或密码输入有误')));
     }
 }