You are here

function drupalgap_logintoboggan_services_login in DrupalGap 7.2

Same name and namespace in other branches
  1. 7 modules/drupalgap_logintoboggan/drupalgap_logintoboggan.module \drupalgap_logintoboggan_services_login()

Replacement callback for the Services user login resource when the LoginToboggan module is enabled. Optionally use the email address to login.

See also

_user_resource_login().

https://drupal.org/node/1431724

1 string reference to 'drupalgap_logintoboggan_services_login'
drupalgap_logintoboggan_services_resources_alter in modules/drupalgap_logintoboggan/drupalgap_logintoboggan.module
Implements hook_services_resources_alter().

File

modules/drupalgap_logintoboggan/drupalgap_logintoboggan.module, line 29

Code

function drupalgap_logintoboggan_services_login($username, $password) {
  if (variable_get('logintoboggan_login_with_email', 0)) {
    $result = db_query("SELECT name FROM {users} WHERE LOWER(mail) = LOWER(:username)", array(
      ':username' => $username,
    ))
      ->fetch();
    if (!empty($result->name)) {
      $username = $result->name;
    }
  }
  return _user_resource_login($username, $password);
}