Logout.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. /** @inheritdoc */
  15. public function minimumPermission() {
  16. return AUTH_NONE;
  17. }
  18. /** @inheritdoc */
  19. public function checkPreconditions() {
  20. parent::checkPreconditions();
  21. /** @var AuthPlugin $auth */
  22. global $auth;
  23. if(!$auth->canDo('logout')) throw new ActionDisabledException();
  24. }
  25. /** @inheritdoc */
  26. public function preProcess() {
  27. global $ID;
  28. global $INPUT;
  29. if (!checkSecurityToken()) throw new ActionException();
  30. // when logging out during an edit session, unlock the page
  31. $lockedby = checklock($ID);
  32. if($lockedby == $INPUT->server->str('REMOTE_USER')) {
  33. unlock($ID);
  34. }
  35. // do the logout stuff and redirect to login
  36. auth_logoff();
  37. send_redirect(wl($ID, array('do' => 'login'), true, '&'));
  38. // should never be reached
  39. throw new ActionException('login');
  40. }
  41. }