Skip to content
Snippets Groups Projects
Commit 48bd2841 authored by Michael Fairchild's avatar Michael Fairchild
Browse files

Fix login bug

Sometimes phpCAS would think we are still logged in, because Elgg doesn't get rid of cookies.
parent 52fb8859
No related branches found
No related tags found
No related merge requests found
...@@ -38,8 +38,11 @@ ...@@ -38,8 +38,11 @@
function login_page_handler($page) { function login_page_handler($page) {
// If we're not logged in, display the login page // If we're not logged in, display the login page
var_dump(elgg_is_logged_in());
if (!elgg_is_logged_in()) { if (!elgg_is_logged_in()) {
$auth = new elggSimpleCas(); $auth = new elggSimpleCas();
echo 'force login';
$auth->forceLogin(); $auth->forceLogin();
} }
...@@ -73,13 +76,15 @@ class elggSimpleCas { ...@@ -73,13 +76,15 @@ class elggSimpleCas {
const DIRECTORY_URL = 'http://directory.unl.edu/'; const DIRECTORY_URL = 'http://directory.unl.edu/';
public static $cert_path = '/etc/pki/tls/cert.pem';
function __construct() { function __construct() {
if (!\phpCAS::isInitialized()) { if (!\phpCAS::isInitialized()) {
\phpCAS::setDebug(); \phpCAS::setDebug();
\phpCAS::setVerbose(true); \phpCAS::setVerbose(true);
\phpCAS::client(CAS_VERSION_2_0, 'login.unl.edu', 443, 'cas', false); \phpCAS::client(CAS_VERSION_2_0, 'login.unl.edu', 443, 'cas');
\phpCAS::setNoCasServerValidation(); \phpCAS::setNoCasServerValidation();
//TODO: \phpCAS::setCasServerCACert($options['CERT_PATH']); //\phpCAS::setCasServerCACert(self::$cert_path);
\phpCAS::setPostAuthenticateCallback(function($logoutTicket) { \phpCAS::setPostAuthenticateCallback(function($logoutTicket) {
$auth = new elggSimpleCas(); $auth = new elggSimpleCas();
...@@ -243,6 +248,9 @@ class elggSimpleCas { ...@@ -243,6 +248,9 @@ class elggSimpleCas {
} }
public function forceLogin() { public function forceLogin() {
//Due to the weirdness of phpCAS, it might think we are still logged in (when we are not)
$_SESSION['phpCAS'] = array();
\phpCAS::forceAuthentication(); \phpCAS::forceAuthentication();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment