Login.php 1009 B

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