function cas_init in CAS 6.3
Same name and namespace in other branches
- 6 cas.module \cas_init()
- 6.2 cas.module \cas_init()
- 7 cas.module \cas_init()
Implementation of hook_init().
Traps a page load to see if authentication is required.
File
- ./
cas.module, line 23 - Enables users to authenticate via a Central Authentication Service (CAS) Cas will currently work if the auto registration is turned on and will create user accounts automatically.
Code
function cas_init() {
global $user;
if (module_exists('cas_test') && arg(0) == 'cas_test') {
// We are destined for a page handled by the cas_test module, so do not
// do any processing here. Necessary for CAS gateway tests.
return;
}
// Process a single-sign out request.
_cas_single_sign_out_check();
// If user is logged in, redirect 'cas' to '<front>' instead of giving 403.
if ($user->uid && $_GET['q'] == 'cas') {
drupal_goto('');
}
// If a user is not logged in, consider using CAS authentication.
if (!$user->uid) {
$force_authentication = _cas_force_login();
$check_authentication = _cas_allow_check_for_login();
if ($force_authentication || $check_authentication) {
cas_login_check($force_authentication);
}
}
}