Passport.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace app\shop\controller;
  3. use app\shop\model\shop\User;
  4. /**
  5. * 商户认证
  6. */
  7. class Passport extends Controller
  8. {
  9. /**
  10. * 商户后台登录
  11. */
  12. public function login()
  13. {
  14. //登录前清空session
  15. session('jjjshop_store', null);
  16. $user = $this->postData();
  17. $user['password'] = salt_hash($user['password']);
  18. $model = new User();
  19. if ($model->checkLogin($user)) {
  20. return $this->renderSuccess('登录成功', $user['username']);
  21. }
  22. return $this->renderError($model->getError()?:'登录失败');
  23. }
  24. /**
  25. * 退出登录
  26. */
  27. public function logout()
  28. {
  29. session('jjjshop_store', null);
  30. return $this->renderSuccess('退出成功');
  31. }
  32. /*
  33. * 修改密码
  34. */
  35. public function editPass()
  36. {
  37. $model = new User();
  38. if ($model->editPass($this->postData(), $this->store['user'])) {
  39. return $this->renderSuccess('修改成功');
  40. }
  41. return $this->renderError($model->getError()?:'修改失败');
  42. }
  43. /**
  44. * 商户后台登录
  45. */
  46. public function saasLogin()
  47. {
  48. //登录前清空session
  49. $store = session('jjjshop_store');
  50. if($store != null){
  51. return $this->renderSuccess('登录成功', $store['user']['user_name']);
  52. }
  53. return $this->renderError('自动登录失败,请手动输入');
  54. }
  55. }