Passport.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\model\admin\User as UserModel;
  4. use think\Session;
  5. /**
  6. * 超管后台认证
  7. * Class Passport
  8. * @package app\store\controller
  9. */
  10. class Passport extends Controller
  11. {
  12. /**
  13. * 超管后台登录
  14. * @return array|mixed
  15. * @throws \think\db\exception\DataNotFoundException
  16. * @throws \think\db\exception\ModelNotFoundException
  17. * @throws \think\exception\DbException
  18. */
  19. public function login()
  20. {
  21. if ($this->request->isAjax()) {
  22. $model = new UserModel;
  23. if ($model->login($this->postData('User'))) {
  24. return $this->renderSuccess('登录成功', url('index/index'));
  25. }
  26. return $this->renderError($model->getError() ?: '登录失败');
  27. }
  28. $this->view->engine->layout(false);
  29. return $this->fetch('login');
  30. }
  31. /**
  32. * 退出登录
  33. */
  34. public function logout()
  35. {
  36. Session::clear('yoshop_admin');
  37. $this->redirect('passport/login');
  38. }
  39. }