Passport.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. *
  4. * @copyright ©2020 点小铺
  5. * @author hanj
  6. * @link: https://dyuit.com
  7. * Created by VSCode
  8. */
  9. namespace app\store\controller;
  10. use app\store\model\store\User as StoreUser;
  11. use think\Session;
  12. /**
  13. * 商户认证
  14. * Class Passport
  15. * @package app\store\controller
  16. */
  17. class Passport extends Controller
  18. {
  19. /**
  20. * 商户后台登录
  21. * @return array|bool|mixed
  22. * @throws \think\Exception
  23. * @throws \think\db\exception\DataNotFoundException
  24. * @throws \think\db\exception\ModelNotFoundException
  25. * @throws \think\exception\DbException
  26. */
  27. public function login()
  28. {
  29. if ($this->request->isAjax()) {
  30. $model = new StoreUser;
  31. if ($model->login($this->postData('User'))) {
  32. return $this->renderSuccess('登录成功', url('index/index'));
  33. }
  34. return $this->renderError($model->getError() ?: '登录失败');
  35. }
  36. $this->view->engine->layout(false);
  37. return $this->fetch('login', [
  38. // 系统版本号
  39. 'version' => get_version()
  40. ]);
  41. }
  42. /**
  43. * 退出登录
  44. */
  45. public function logout()
  46. {
  47. Session::clear('dyu_store');
  48. $this->redirect('passport/login');
  49. }
  50. }