您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

52 行
1.5KB

  1. <?php
  2. namespace App\Filters;
  3. use CodeIgniter\Filters\FilterInterface;
  4. use CodeIgniter\HTTP\RequestInterface;
  5. use CodeIgniter\HTTP\ResponseInterface;
  6. class AdminFilter implements FilterInterface
  7. {
  8. /**
  9. * Do whatever processing this filter needs to do.
  10. * By default it should not return anything during
  11. * normal execution. However, when an abnormal state
  12. * is found, it should return an instance of
  13. * CodeIgniter\HTTP\Response. If it does, script
  14. * execution will end and that Response will be
  15. * sent back to the client, allowing for error pages,
  16. * redirects, etc.
  17. *
  18. * @param RequestInterface $request
  19. * @param array|null $arguments
  20. *
  21. * @return mixed
  22. */
  23. public function before(RequestInterface $request, $arguments = null)
  24. {
  25. $session = session();
  26. $loggedIn = $session->is_logged;
  27. if (!$loggedIn) {
  28. return redirect()->route('admin_login');
  29. }
  30. }
  31. /**
  32. * Allows After filters to inspect and modify the response
  33. * object as needed. This method does not allow any way
  34. * to stop execution of other after filters, short of
  35. * throwing an Exception or Error.
  36. *
  37. * @param RequestInterface $request
  38. * @param ResponseInterface $response
  39. * @param array|null $arguments
  40. *
  41. * @return mixed
  42. */
  43. public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
  44. {
  45. //
  46. }
  47. }