diff --git a/sites/all/modules/unl/unl_cas.module b/sites/all/modules/unl/unl_cas.module index 0a0a5723bc421bab7991ccf7a5bf1dbf35304b86..eee6366cf37c1866796e1102845a2208012ad4b3 100644 --- a/sites/all/modules/unl/unl_cas.module +++ b/sites/all/modules/unl/unl_cas.module @@ -5,24 +5,29 @@ function unl_cas_init() require_once dirname(__FILE__) . '/lib/CAS/CAS.php'; phpCAS::client(CAS_VERSION_2_0,'login.unl.edu',443,'/cas'); phpCAS::setNoCasServerValidation(); + phpCAS::handleLogoutRequests(); if (!array_key_exists('last_sso_check', $_SESSION)) { $_SESSION['unl']['last_sso_check'] = 0; } + $auth = FALSE; if (array_key_exists('unl_sso', $_COOKIE)) { $auth = phpCAS::checkAuthentication(); - if ($auth) { - $username = phpCAS::getUser(); - $user = user_load_by_name($username); - if (!$user) { - $user = unl_cas_import_user($username); - } - if ($GLOBALS['user']->uid != $user->uid) { - $GLOBALS['user'] = $user; - user_login_finalize(); - } + } + if ($auth) { + $username = phpCAS::getUser(); + $user = user_load_by_name($username); + if (!$user) { + $user = unl_cas_import_user($username); + } + if ($GLOBALS['user']->uid != $user->uid) { + $GLOBALS['user'] = $user; + user_login_finalize(); } + } else if (!user_is_anonymous()) { + $GLOBALS['user'] = drupal_anonymous_user(); + user_login_finalize(); } }