function user_service_login in Services 5
Same name and namespace in other branches
- 6 services/user_service/user_service.inc \user_service_login()
- 6.2 services/user_service/user_service.inc \user_service_login()
- 7 services/user_service/user_service.inc \user_service_login()
login a user
1 string reference to 'user_service_login'
- user_service_service in services/
user_service/ user_service.module - Implementation of hook_service().
File
- services/
user_service/ user_service.module, line 57 - The module which exposes services related to user activities
Code
function user_service_login($username, $password) {
global $user;
if ($user->uid) {
// user is already logged in
return services_error(t('Already logged in as !user.', array(
'!user' => $user->name,
)));
}
$user = user_authenticate($username, $password);
if ($user->uid) {
// Regenerate the session ID to prevent against session fixation attacks.
sess_regenerate();
module_invoke_all('user', 'login', NULL, $user);
$return = new stdClass();
$return->sessid = session_id();
$return->user = $user;
return $return;
}
session_destroy();
return services_error(t('Wrong username or password.'));
}