function ip_login_user_logout in IP Login 6.2
Same name and namespace in other branches
- 7.3 ip_login.module \ip_login_user_logout()
- 7.2 ip_login.module \ip_login_user_logout()
- 4.x ip_login.module \ip_login_user_logout()
Logs the current user out.
Called from hook_user on logout, most of the code taken from user_logout() and _drupal_bootstrap().
1 call to ip_login_user_logout()
- ip_login_user in ./
ip_login.module - Implementation of hook_user().
File
- ./
ip_login.module, line 508 - Allow user login by IP addresses, ranges or wildcards.
Code
function ip_login_user_logout() {
// prevent recursive call via user_module_invoke() / module_invoke_all() in user.pages.inc
if (!ip_login_is_possible()) {
return;
}
else {
$_SESSION[IP_CHECKED] = FALSE;
$_SESSION[IP_UID_MATCH] = 0;
}
global $user;
// store whether this user can log back in automatically
$can_login_as_another_user = _ip_login_can_login_as_another_user($user);
// sets indicator to behaviour in hook_boot().
$expire = 0;
// Cookie expires at the end of the session (when the browser closes).
setcookie(LOGIN_AS_DIFFERENT_USER, $can_login_as_another_user, $expire, '/');
if (!$can_login_as_another_user) {
// @todo: it is possible that some other hook_user_logout() has been called already
// does this generate an undetermined state?
$message = t(variable_get('ip_login_logged_back_in', 'This account does not have permission to log out once logged in automatically. You have been logged back in.'));
$message = token_replace($message, array(
'user' => $user,
), array(
'clear' => TRUE,
));
drupal_set_message($message, 'warning');
// show the login page
drupal_goto(variable_get('ip_login_destination', 'user'));
}
}