Move logout to a routing callback

This commit is contained in:
ohartl 2016-02-23 04:42:08 +01:00
parent 39a38be904
commit 1f736a9746
3 changed files with 16 additions and 6 deletions

View file

@ -116,6 +116,17 @@ class Auth
}
/**
* @return void
*/
public static function logout()
{
unset($_SESSION[static::SESSION_IDENTIFIER]);
session_destroy();
}
/**
* Check if current user has a certain role, but User::ROLE_ADMIN will have access to all
*

View file

@ -1,5 +0,0 @@
<?php
require_once 'include/php/default.inc.php';
session_destroy();
redirect('/');

View file

@ -7,7 +7,11 @@ Router::addGet('/', 'include/php/pages/start.php');
* Auth
*/
Router::addMixed('/login', 'include/php/pages/login.php');
Router::addGet('/logout', 'include/php/pages/logout.php');
Router::addGet('/logout', function(){
Auth::logout();
redirect('/');
return;
});
/**
* Private area