protected function EntityShareServerRestAbstract::doLogin in Entity Share 7
Authenticate the user.
1 call to EntityShareServerRestAbstract::doLogin()
- EntityShareServerRestAbstract::handle in modules/
entity_share_server/ includes/ entity_share_server.rest.abstract.inc - Handle the server.
File
- modules/
entity_share_server/ includes/ entity_share_server.rest.abstract.inc, line 433 - Class for handling Entity Share Rest Server request.
Class
- EntityShareServerRestAbstract
- Abstract Class to manage the EntityShare Rest server.
Code
protected function doLogin() {
// Get the login and password.
$login = $this
->getParam('datas')->login;
$password = $this
->getParam('datas')->password;
// Authenticate user in drupal.
global $user;
$account = user_authenticate($login, $password);
if (!$account) {
$this
->setError('Invalid user');
return;
}
// Update the drupal loaded user.
$user = user_load($account, TRUE);
// Regenerate the session for security reason.
drupal_session_regenerate();
// Get the session informations.
$session_name = session_name();
$session_id = session_id();
if (!empty($session_name) && !empty($session_id)) {
$this
->setResult(array(
'session_name' => $session_name,
'session_id' => $session_id,
));
}
else {
$this
->setError('User session invalid');
}
}