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

View file

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