LoginController.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\matchmaker\controller;
  3. use app\matchmaker\model\MatchmakerModel;
  4. use cmf\controller\HomeBaseController;
  5. class LoginController extends HomeBaseController
  6. {
  7. /**
  8. * 登录
  9. */
  10. public function index()
  11. {
  12. return $this->fetch();
  13. }
  14. public function login()
  15. {
  16. $param = $this->request->param();
  17. if (empty($param['mobile']) || empty($param['password'])) {
  18. $this->error('请输入手机号或密码');
  19. }
  20. $matchmaker = MatchmakerModel::where('mobile',$param['mobile'])->find();
  21. if (empty($matchmaker)) {
  22. $this->error('手机号错误');
  23. }
  24. if ($matchmaker['status'] != 1) {
  25. $this->error('该账号已经被封禁');
  26. }
  27. if ($matchmaker['password'] != $param['password']) {
  28. $this->error('密码错误');
  29. }
  30. session('matchmaker.id',$matchmaker['id']);
  31. $this->success('登录成功');
  32. }
  33. /**
  34. * 退出登录
  35. */
  36. public function logout()
  37. {
  38. session("matchmaker", null);//只有前台用户退出
  39. return redirect(cmf_url("matchmaker/Login/index"));
  40. }
  41. }