You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

56 lines
1.2 KiB

  1. <?php
  2. namespace dokuwiki\Action;
  3. use dokuwiki\Action\Exception\ActionDisabledException;
  4. use dokuwiki\Action\Exception\ActionException;
  5. use dokuwiki\Extension\AuthPlugin;
  6. /**
  7. * Class Logout
  8. *
  9. * Log out a user
  10. *
  11. * @package dokuwiki\Action
  12. */
  13. class Logout extends AbstractUserAction
  14. {
  15. /** @inheritdoc */
  16. public function minimumPermission()
  17. {
  18. return AUTH_NONE;
  19. }
  20. /** @inheritdoc */
  21. public function checkPreconditions()
  22. {
  23. parent::checkPreconditions();
  24. /** @var AuthPlugin $auth */
  25. global $auth;
  26. if (!$auth->canDo('logout')) throw new ActionDisabledException();
  27. }
  28. /** @inheritdoc */
  29. public function preProcess()
  30. {
  31. global $ID;
  32. global $INPUT;
  33. if (!checkSecurityToken()) throw new ActionException();
  34. // when logging out during an edit session, unlock the page
  35. $lockedby = checklock($ID);
  36. if ($lockedby == $INPUT->server->str('REMOTE_USER')) {
  37. unlock($ID);
  38. }
  39. // do the logout stuff and redirect to login
  40. auth_logoff();
  41. send_redirect(wl($ID, ['do' => 'login'], true, '&'));
  42. // should never be reached
  43. throw new ActionException('login');
  44. }
  45. }