Passport.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\store\controller;
  3. use app\store\model\store\User as StoreUser;
  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|bool|mixed
  15. * @throws \think\Exception
  16. * @throws \think\db\exception\DataNotFoundException
  17. * @throws \think\db\exception\ModelNotFoundException
  18. * @throws \think\exception\DbException
  19. */
  20. public function login()
  21. {
  22. if ($this->request->isAjax()) {
  23. $model = new StoreUser;
  24. if ($model->login($this->postData('User'))) {
  25. return $this->renderSuccess('登录成功', url('index/index'));
  26. }
  27. return $this->renderError($model->getError() ?: '登录失败');
  28. }
  29. $this->view->engine->layout(false);
  30. return $this->fetch('login', [
  31. // 系统版本号
  32. 'version' => get_version()
  33. ]);
  34. }
  35. /**
  36. * 退出登录
  37. */
  38. public function logout()
  39. {
  40. Session::clear('yoshop_store');
  41. $this->redirect('passport/login');
  42. }
  43. }