Here is the code for the ControllerBase:
<?php
use Phalcon\Mvc\Controller;
use Phalcon\Loader;
class ControllerBase extends Controller
{
public function initialize()
{
/* Login logic */
if ( $_POST['loginAttempt'] == "true" )
{
//Store the password the user supplied
$this->session->set( 'username', $_POST['username'] );
$password = $_POST['password'] ;
/* Some other, not applicable logic takes place right here, omitted */
if ( isset($userData[0]->userId) )
{
$this->session->set( 'userId', $userData[0]->userId );
$this->session->set( 'userData', $userData[0] );
$this->session->set( 'apiKey', $token );
}
else //Makes it blank, which causes the logic later below to kick them
{
$this->session->set( 'userId', '' );
}
//Get user's groups from the LDAP server
$this->session->set( 'userGroups', $ldapObj->memberOf() );
}
}
//If no userId is present in the session (or session doesn't exist, so
//it's empty), kick 'em out
if ( empty( $this->session->get('userId') ) )
{
//Log them out/redirect to login page
$this->logout();
}
/* End Login logic */
}
/**
*
* Log out current user
*/
function logout()
{
//Destroy session if it exists
if ( !empty( $this->session->get('userId') ) )
{
$this->session->destroy();
}
//Redirect to the login page
return $this->dispatcher->forward(array(
'controller' => 'login', 'action' => 'index'
));
}
Here is the WikiController applicable code:
<?php
class WikiController extends ControllerBase
{
/* This is to always redirect to the View Action, in case something brings the user to the .com/wiki/ page
function indexAction() */
{
//Redirect to the report run
return $this->dispatcher->forward(array(
'controller' => 'wiki', 'action' => 'view', 'params' => array( 0 => 'system:all' )
));
}
function viewAction($wiki_word) {
$wikis = new WikiModel();
/* Promptly set a few things then asks the model for some MySQL results, which is where the errors pop
onto the browser's output, I don't know how I get where if the session userId is not set, since I assume the
logout() should have been called, and by putting a die('here'); into logout(), I confirmed it IS being called, but
it is not kicking them to the login page */
}