Created
June 30, 2012 00:43
-
-
Save sunnywalker/3021610 to your computer and use it in GitHub Desktop.
Using the UHLoginService PHP class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// assume session_start(); somewhere prior to this | |
//set the user level based on the uh username (could also check a database or something) | |
//this function, if it exists, will get called by the class | |
function getUserLevelByName($uh_username) { | |
return in_array($uh_username, array('swalker', 'jvelasqu')) ? 100 : 10; //these people get 100 user level, everybody else gets a 10 | |
} | |
//include the php class | |
require_once('/path/to/includes/_UHLoginService.php'); | |
//set up the app (used for session variables and login/logout forwarding | |
$login = new UHLoginService('NameOfApp', '/path/to/app/'); | |
//require 'hawcc' campus affiliation | |
$login->setRestriction('campus', 'hawcc'); | |
//require 'staff' affiliation | |
$login->setRestriction('affiliation', 'staff'); | |
//handle the login/logout ticketing to/from the CAS | |
$login->processQueue(); | |
//make sure they've successfully logged in (mandatory login) | |
$login->checkLogin(); | |
//... elsewhere in the page | |
if ($login->isLevel(100)) { | |
//this stuff is for admins only, with 100 user level | |
} | |
//and to allow a logout | |
echo '<a href="./?logout">Log out</a>'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment