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