function cas_server_login in CAS 7
Same name and namespace in other branches
- 5.4 cas_server.module \cas_server_login()
- 5.3 cas_server.module \cas_server_login()
- 6.3 cas_server.module \cas_server_login()
- 6.2 cas_server.module \cas_server_login()
Handle login
1 string reference to 'cas_server_login'
- cas_server_menu in ./
cas_server.module - Implementation of hook_menu
File
- ./
cas_server.module, line 138 - Provides a protocol compliant version of CAS server 2.x
Code
function cas_server_login() {
// Set login cookie so that we know we're in the process of logging in
global $user;
$output = '';
$whitelist_error_msg = variable_get('cas_server_whitelist_failure', t('You do not have permission to login to CAS from this service.'));
$service = isset($_REQUEST['service']) ? $_REQUEST['service'] : '';
$gateway = isset($_REQUEST['gateway']);
if ($user->uid) {
if ($service) {
// Check service against whitelist
if (!_cas_server_check_service_whitelist($service)) {
return $whitelist_error_msg;
}
else {
$_COOKIE[CAS_LOGIN_COOKIE] = $service;
}
}
$output = t('You have successfully logged into CAS');
cas_server_service_return();
}
else {
if ($gateway && $service) {
drupal_goto($service);
}
else {
// Redirect to user login
if ($service) {
// Check service against whitelist
if (!_cas_server_check_service_whitelist($service)) {
return $whitelist_error_msg;
}
else {
setcookie(CAS_LOGIN_COOKIE, $service);
}
}
$output .= l(t('Login'), 'user', array(
'query' => array(
'destination' => 'cas/login',
),
));
drupal_goto('user/login', array(
'query' => array(
'destination' => 'cas/login',
),
));
}
}
return $output;
}