From 5d50a8125d5d18c7c46cf9cedef8559220f7f1a3 Mon Sep 17 00:00:00 2001 From: inghamn Date: Tue, 2 Feb 2010 15:57:08 +0000 Subject: [PATCH] Added support for CAS authentication git-svn-id: https://rosehill.googlecode.com/svn/trunk@67 100bd78a-fc82-11de-b5bc-ffd2847a4b57 --- html/login/home.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/html/login/home.php b/html/login/home.php index f3433d4..a52845d 100644 --- a/html/login/home.php +++ b/html/login/home.php @@ -9,7 +9,7 @@ if (isset($_REQUEST['return_url'])) { $_SESSION['return_url'] = $_REQUEST['return_url']; } -require_once '/var/www/libraries/SimpleCAS/SimpleCAS/Autoload.php'; +require_once CAS.'/SimpleCAS/Autoload.php'; $options = array('hostname'=>CAS_SERVER,'uri'=>CAS_URI); $protocol = new SimpleCAS_Protocol_Version2($options); @@ -17,17 +17,22 @@ $client = SimpleCAS::client($protocol); $client->forceAuthentication(); if ($client->isAuthenticated()) { - $user = new User($client->getUsername()); - $user->startNewSession(); - setcookie(CAS_COOKIE,'true',0,'/',CAS_DOMAIN); + try { + $user = new User($client->getUsername()); + $user->startNewSession(); + setcookie(CAS_COOKIE,'true',0,'/',CAS_DOMAIN); - if (isset($_SESSION['return_url'])) { - header('Location: '.$_SESSION['return_url']); + 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; } } else { - echo "Could not log in"; + header('Location: '.BASE_URL); }