function account_sync_sso_login in Account Sync 6
Same name and namespace in other branches
- 7.2 account_sync_sso/account_sync_sso.module \account_sync_sso_login()
Login the specified user.
1 string reference to 'account_sync_sso_login'
- account_sync_sso_menu in account_sync_sso/
account_sync_sso.module - Implementation of hook_menu().
File
- account_sync_sso/
account_sync_sso.module, line 56 - Handle single signon functionality for the account sync module
Code
function account_sync_sso_login($username, $timestamp, $hashed_pass) {
global $user;
$target = account_sync_target_path(func_get_args(), 3);
if ($user->uid) {
// A user is already logged in, so ignore the attempt and go to the
// target url.
drupal_goto($target);
}
if ($account = account_sync_validate_login($username, $timestamp, $hashed_pass)) {
// All checks passed, so lets log in the user.
$user = $account;
watchdog('user', 'Account sync sso: Session opened for %name.', array(
'%name' => $user->name,
));
$user->login = time();
db_query("UPDATE {users} SET login = %d WHERE uid = %d", $user->login, $user->uid);
// Regenerate the session ID to prevent against session fixation attacks.
sess_regenerate();
$edit = array();
user_module_invoke('login', $edit, $user);
drupal_goto($target);
}
}