You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
1.7 KiB

  1. <?php
  2. namespace backend\controllers;
  3. use antgoods\goods\models\ars\Goods;
  4. use Yii;
  5. use yii\base\NotSupportedException;
  6. use yii\web\Controller;
  7. use yii\filters\VerbFilter;
  8. use yii\filters\AccessControl;
  9. use common\models\LoginForm;
  10. use common\models\CategorySearch;
  11. use yii\web\Cookie;
  12. use yii\web\ForbiddenHttpException;
  13. use yii\web\NotAcceptableHttpException;
  14. use yii\web\NotFoundHttpException;
  15. /**
  16. * Site controller
  17. */
  18. class SiteController extends Controller
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function actions()
  24. {
  25. return [
  26. 'error' => [
  27. 'class' => 'yii\web\ErrorAction',
  28. ],
  29. 'upload' => [
  30. 'class' => 'iron\actions\UploadAction',
  31. ]
  32. ];
  33. }
  34. /**
  35. * Displays homepage.
  36. *
  37. * @return string
  38. */
  39. public function actionIndex()
  40. {
  41. return $this->render('index');
  42. }
  43. public function actionLogin()
  44. {
  45. if (!Yii::$app->user->isGuest) {
  46. return $this->goHome();
  47. }
  48. $key = Yii::$app->request->get('key');
  49. if (Yii::$app->userLogic->login($key)) {
  50. return $this->goBack();
  51. } else {
  52. throw new ForbiddenHttpException('身份验证失败,请重新进去');
  53. }
  54. }
  55. /**
  56. * Logout action.
  57. *
  58. * @return string
  59. */
  60. public function actionLogout()
  61. {
  62. Yii::$app->user->logout();
  63. return $this->goHome();
  64. }
  65. public function actionTest()
  66. {
  67. $searchModel = new CategorySearch();
  68. return $this->render('test', [
  69. 'name' => 'blobt',
  70. 'model' => $searchModel
  71. ]);
  72. }
  73. }