You are here

drupalgap_email_registration.module in DrupalGap 7

File

modules/drupalgap_email_registration/drupalgap_email_registration.module
View source
<?php

/**
 * Implements hook_services_resources_alter().
 */
function drupalgap_email_registration_services_resources_alter(&$resources, &$endpoint) {

  // Override the normal user login callback.
  if (isset($resources['user']['actions']['login']['callback'])) {
    $resources['user']['actions']['login']['callback'] = 'drupalgap_email_registration_services_login';
  }
}

/**
 * Replacement callback for the Services user login resource when the
 * Email Registration module is enabled. Use the email address to login.
 *
 * @see _user_resource_login().
 */
function drupalgap_email_registration_services_login($username, $password) {
  $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);
}

Functions

Namesort descending Description
drupalgap_email_registration_services_login Replacement callback for the Services user login resource when the Email Registration module is enabled. Use the email address to login.
drupalgap_email_registration_services_resources_alter Implements hook_services_resources_alter().