Pleets /
SQLWebManager
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Auth\Controller; |
||
| 4 | |||
| 5 | use Drone\Mvc\AbstractionController; |
||
| 6 | use Drone\Network\Http; |
||
| 7 | |||
| 8 | class LogOut extends AbstractionController |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Closes the user session |
||
| 12 | * |
||
| 13 | * @return null |
||
| 14 | */ |
||
| 15 | public function close() |
||
| 16 | { |
||
| 17 | # STANDARD VALIDATIONS [check method] |
||
| 18 | if (!$this->isGet()) |
||
| 19 | { |
||
| 20 | $http = new Http(); |
||
| 21 | $http->writeStatus($http::HTTP_METHOD_NOT_ALLOWED); |
||
| 22 | |||
| 23 | die('Error ' . $http::HTTP_METHOD_NOT_ALLOWED .' (' . $http->getStatusText($http::HTTP_METHOD_NOT_ALLOWED) . ')!!'); |
||
|
0 ignored issues
–
show
|
|||
| 24 | } |
||
| 25 | |||
| 26 | $config = include 'module/Auth/config/user.config.php'; |
||
| 27 | $method = $config["authentication"]["method"]; |
||
| 28 | $key = $config["authentication"]["key"]; |
||
| 29 | |||
| 30 | switch ($method) |
||
| 31 | { |
||
| 32 | case '_COOKIE': |
||
| 33 | if (array_key_exists($key, $_COOKIE) || !empty($_COOKIE[$key])) |
||
| 34 | setcookie($key, $_COOKIE[$key], time() - 1, '/'); |
||
| 35 | break; |
||
| 36 | |||
| 37 | case '_SESSION': |
||
| 38 | session_destroy(); |
||
| 39 | break; |
||
| 40 | } |
||
| 41 | |||
| 42 | header("location: " . $this->getBasePath() . "/public/Auth"); |
||
| 43 | } |
||
| 44 | } |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.