diff --git a/backend/controllers/SiteController.php b/backend/controllers/SiteController.php index bd5c7b0..549bdd5 100755 --- a/backend/controllers/SiteController.php +++ b/backend/controllers/SiteController.php @@ -2,28 +2,20 @@ namespace backend\controllers; -use antgoods\goods\models\ars\Goods; +use backend\logic\PermissionManager; +use ReflectionException; use Yii; -use yii\base\NotSupportedException; +use yii\base\InvalidConfigException; use yii\web\Controller; use yii\filters\VerbFilter; use yii\filters\AccessControl; -use common\models\LoginForm; -use common\models\CategorySearch; -use yii\web\Cookie; -use yii\web\ForbiddenHttpException; -use yii\web\NotAcceptableHttpException; -use yii\web\NotFoundHttpException; -use backend\logic\PermissionManager; -use ReflectionException; -use yii\base\InvalidConfigException; +use backend\models\LoginForm; /** * Site controller * @DESCRIBE 网站基本权限 DESCRIBE */ -class SiteController extends Controller -{ +class SiteController extends Controller { /** * {@inheritdoc} @@ -61,8 +53,8 @@ class SiteController extends Controller 'error' => [ 'class' => 'yii\web\ErrorAction', ], - 'upload' => [ - 'class' => 'iron\actions\UploadAction', + 'upload'=>[ + 'class'=>'iron\actions\UploadAction', ] ]; } @@ -72,8 +64,7 @@ class SiteController extends Controller * * @return string */ - public function actionIndex() - { + public function actionIndex() { return $this->render('index'); } @@ -82,19 +73,24 @@ class SiteController extends Controller * * @return string * @ACTION 登录 ACTION - * @throws ForbiddenHttpException */ public function actionLogin() { $this->layout = 'base'; + if (!Yii::$app->user->isGuest) { return $this->goHome(); } - $key = Yii::$app->request->get('key'); - if (Yii::$app->userLogic->login($key)) { + + $model = new LoginForm(); + if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); } else { - throw new ForbiddenHttpException('身份验证失败,请重新进去'); + $model->password = ''; + + return $this->render('login', [ + 'model' => $model, + ]); } } @@ -104,8 +100,7 @@ class SiteController extends Controller * @return string * @ACTION 登出 ACTION */ - public function actionLogout() - { + public function actionLogout() { Yii::$app->user->logout(); return $this->goHome(); @@ -122,4 +117,4 @@ class SiteController extends Controller return PermissionManager::getAppPermission(); } -} +} \ No newline at end of file