Fixed local authentication when CAS is not available

git-svn-id: https://rosehill.googlecode.com/svn/trunk@74 100bd78a-fc82-11de-b5bc-ffd2847a4b57
This commit is contained in:
inghamn 2013-08-01 19:43:55 +00:00
parent ab0529b7e8
commit 703f49b711
1 changed files with 28 additions and 21 deletions

View File

@ -6,32 +6,39 @@
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt * @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov> * @author Cliff Ingham <inghamn@bloomington.in.gov>
*/ */
if (isset($_REQUEST['return_url'])) { if (defined('CAS')) {
$_SESSION['return_url'] = $_REQUEST['return_url']; if (isset($_REQUEST['return_url'])) {
} $_SESSION['return_url'] = $_REQUEST['return_url'];
require_once CAS.'/SimpleCAS/Autoload.php'; }
$options = array('hostname'=>CAS_SERVER,'uri'=>CAS_URI); require_once CAS.'/SimpleCAS/Autoload.php';
$protocol = new SimpleCAS_Protocol_Version2($options);
$client = SimpleCAS::client($protocol);
$client->forceAuthentication();
if ($client->isAuthenticated()) { $options = array('hostname'=>CAS_SERVER,'uri'=>CAS_URI);
try { $protocol = new SimpleCAS_Protocol_Version2($options);
$user = new User($client->getUsername()); $client = SimpleCAS::client($protocol);
$user->startNewSession(); $client->forceAuthentication();
if (isset($_SESSION['return_url'])) { if ($client->isAuthenticated()) {
header('Location: '.$_SESSION['return_url']); try {
$user = new User($client->getUsername());
$user->startNewSession();
if (isset($_SESSION['return_url'])) {
header('Location: '.$_SESSION['return_url']);
}
else {
header('Location: '.BASE_URL);
}
} }
else { catch (Exception $e) {
header('Location: '.BASE_URL); $_SESSION['errorMessages'][] = $e;
} }
} }
catch (Exception $e) { else {
$_SESSION['errorMessages'][] = $e; header('Location: '.BASE_URL);
} }
} }
else {
header('Location: '.BASE_URL); $template = new Template();
} $template->blocks[] = new Block('loginForm.inc');
echo $template->render();