AccountController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace backend\controllers;
  3. use backend\models\forms\LoginForm;
  4. use backend\models\forms\OpenDemoForm;
  5. use backend\models\forms\OpenForm;
  6. use backend\models\forms\PwdForm;
  7. use backend\models\forms\RePwdForm;
  8. use backend\models\MemberApi;
  9. use backend\models\SmsApi;
  10. use Yii;
  11. use yii\helpers\Html;
  12. use yii\web\Controller;
  13. use yii\web\UploadedFile;
  14. use backend\models\MemberIdentity;
  15. class AccountController extends Controller
  16. {
  17. public $enableCsrfValidation = false;
  18. /**
  19. * 管理员登录页面
  20. * @return string
  21. */
  22. public function actionAdminlogin()
  23. {
  24. return $this->renderPartial('adminlogin');
  25. }
  26. /**
  27. * 管理员登录验证
  28. * @return \yii\web\Response
  29. */
  30. public function actionAdminloginPost()
  31. {
  32. $model = new LoginForm();
  33. if (Yii::$app->getRequest()->getIsPost()) {
  34. $model->setAttributes(Yii::$app->getRequest()->post());
  35. $model->type = MemberIdentity::MEMBER_TYPE_ADMIN;
  36. if ($model->login()) {
  37. return $this->asJson([
  38. 'isSuccess' => true,
  39. ]);
  40. }
  41. }
  42. return $this->asJson([
  43. 'isSuccess' => false,
  44. 'msg' => Html::errorSummary($model, ['header' => '']),
  45. ]);
  46. }
  47. /**
  48. * 登出
  49. */
  50. public function actionLogout()
  51. {
  52. $redirectAction = '/adminL0gin3721';
  53. Yii::$app->user->logout(false);
  54. $this->redirect([$redirectAction]);
  55. }
  56. }