Validate if github_token exists

Validate if the github_token session key exists before call it
This commit is contained in:
Kinn Coelho Julião 2013-05-16 18:06:01 -04:00
parent 3b196a3072
commit 3f9b678d2b
2 changed files with 5 additions and 3 deletions

View file

@ -107,6 +107,8 @@ class ProjectController extends b8\Controller
*/ */
public function add() public function add()
{ {
$_SESSION['github_token'] = isset($_SESSION['github_token']) ? $_SESSION['github_token'] : null;
if (!Registry::getInstance()->get('user')->getIsAdmin()) { if (!Registry::getInstance()->get('user')->getIsAdmin()) {
throw new \Exception('You do not have permission to do that.'); throw new \Exception('You do not have permission to do that.');
} }
@ -151,7 +153,7 @@ class ProjectController extends b8\Controller
$view->project = null; $view->project = null;
$view->form = $form; $view->form = $form;
$view->key = $pub; $view->key = $pub;
$view->token = $_SESSION['github_token'] ? $_SESSION['github_token'] : null; $view->token = $_SESSION['github_token'];
return $view->render(); return $view->render();
} }

View file

@ -70,8 +70,8 @@ class SessionController extends b8\Controller
*/ */
public function logout() public function logout()
{ {
unset($_SESSION['user_id']); $_SESSION = array();
unset($_SESSION['github_token']); session_destroy();
header('Location: /'); header('Location: /');
die; die;
} }