Login.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. declare (strict_types = 1);
  3. /**
  4. * +----------------------------------------------------------------------
  5. * | 后台登录控制制器
  6. * +----------------------------------------------------------------------
  7. */
  8. namespace app\controller\sys;
  9. // 引入框架内置类
  10. use think\facade\View;
  11. use think\facade\Session;
  12. use think\facade\Request;
  13. use think\captcha\facade\Captcha;
  14. use app\utils\ReUtils;
  15. use app\model\SysUser;
  16. use app\model\SysLoginFail;
  17. use app\model\SysLoginNote;
  18. class Login
  19. {
  20. // 登录页面
  21. public function index()
  22. {
  23. // 已登录自动跳转
  24. if (Session::has('adminuser')) {
  25. return redirect((string)url('/sys/index/index'));
  26. }
  27. $restore_url = Session::has('restore') ? Session::get('restore'): (string)url('index/index');
  28. View::assign('restore_url', $restore_url);
  29. return View::fetch();
  30. }
  31. // 校验登录
  32. public function checkLogin(){
  33. return SysUser::checkLogin();
  34. }
  35. // 退出登录
  36. public function logout(){
  37. Session::delete('adminuser');
  38. return redirect((string) url('login/index'));
  39. }
  40. }