From 703f49b711a173a0d10db3d7da9014b23188dbb8 Mon Sep 17 00:00:00 2001 From: inghamn Date: Thu, 1 Aug 2013 19:43:55 +0000 Subject: [PATCH] Fixed local authentication when CAS is not available git-svn-id: https://rosehill.googlecode.com/svn/trunk@74 100bd78a-fc82-11de-b5bc-ffd2847a4b57 --- html/login/home.php | 49 ++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/html/login/home.php b/html/login/home.php index bd5a51e..a55922e 100644 --- a/html/login/home.php +++ b/html/login/home.php @@ -6,32 +6,39 @@ * @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt * @author Cliff Ingham */ -if (isset($_REQUEST['return_url'])) { - $_SESSION['return_url'] = $_REQUEST['return_url']; -} -require_once CAS.'/SimpleCAS/Autoload.php'; +if (defined('CAS')) { + if (isset($_REQUEST['return_url'])) { + $_SESSION['return_url'] = $_REQUEST['return_url']; + } -$options = array('hostname'=>CAS_SERVER,'uri'=>CAS_URI); -$protocol = new SimpleCAS_Protocol_Version2($options); -$client = SimpleCAS::client($protocol); -$client->forceAuthentication(); + require_once CAS.'/SimpleCAS/Autoload.php'; -if ($client->isAuthenticated()) { - try { - $user = new User($client->getUsername()); - $user->startNewSession(); + $options = array('hostname'=>CAS_SERVER,'uri'=>CAS_URI); + $protocol = new SimpleCAS_Protocol_Version2($options); + $client = SimpleCAS::client($protocol); + $client->forceAuthentication(); - if (isset($_SESSION['return_url'])) { - header('Location: '.$_SESSION['return_url']); + if ($client->isAuthenticated()) { + try { + $user = new User($client->getUsername()); + $user->startNewSession(); + + if (isset($_SESSION['return_url'])) { + header('Location: '.$_SESSION['return_url']); + } + else { + header('Location: '.BASE_URL); + } } - else { - header('Location: '.BASE_URL); + catch (Exception $e) { + $_SESSION['errorMessages'][] = $e; } } - catch (Exception $e) { - $_SESSION['errorMessages'][] = $e; + else { + header('Location: '.BASE_URL); } } -else { - header('Location: '.BASE_URL); -} + +$template = new Template(); +$template->blocks[] = new Block('loginForm.inc'); +echo $template->render();