Move logout to a routing callback
This commit is contained in:
parent
39a38be904
commit
1f736a9746
3 changed files with 16 additions and 6 deletions
|
@ -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
|
||||
*
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
<?php
|
||||
require_once 'include/php/default.inc.php';
|
||||
|
||||
session_destroy();
|
||||
redirect('/');
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue