| Total Complexity | 4 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 2 | Features | 0 |
| 1 | <?php |
||
| 28 | class LogoutPage extends HTMLPage { |
||
| 29 | |||
| 30 | protected $error = false; |
||
| 31 | |||
| 32 | public function setCustomHeader() { |
||
| 33 | //check, if session was started |
||
| 34 | PHPUtils::checkSessionStarted(); |
||
| 35 | |||
| 36 | if (!Security::checkCSRFToken()) { |
||
| 37 | $this->error = true; |
||
| 38 | |||
| 39 | //dont logout user, because csrf token isnt correct |
||
| 40 | return; |
||
| 41 | } |
||
| 42 | |||
| 43 | //logout user |
||
| 44 | User::current()->logout(); |
||
| 45 | |||
| 46 | //get domain |
||
| 47 | $domain = Registry::singleton()->getObject("domain"); |
||
| 48 | |||
| 49 | //generate index url |
||
| 50 | $index_url = DomainUtils::generateURL($domain->getHomePage()); |
||
| 51 | |||
| 52 | header("Location: " . $index_url); |
||
| 53 | |||
| 54 | //flush gzip buffer |
||
| 55 | ob_end_flush(); |
||
| 56 | |||
| 57 | exit; |
||
|
|
|||
| 58 | } |
||
| 59 | |||
| 60 | public function getContent(): string { |
||
| 66 | } |
||
| 67 | |||
| 71 |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.