if email is supplied instead of username to log in it fails to authenticate the user.

Comments

d34dman’s picture

StatusFileSize
new604 bytes

Submitting a patch which enabled me to use user email for login.

marcingy’s picture

Status: Active » Closed (won't fix)

Drupal core does not support this so services won't either

muschpusch’s picture

I think it's a nice feature to have since lot's of people use email registration module 10000+ but the patch is not applying to services dev :(

d34dman’s picture

StatusFileSize
new781 bytes

marcingy hope you wont mind me uploading this patch for others who would want to use it. As you can see this function can eliminate the need to create another resource just for this purpose. Also as more and more sites are using user email instead of username to login, i strongly feely this to be a valid feature request.

PS: The patch in comment 1 was submitted in Rest_auth queue and got mixed up with services user resources. My apologies for that.

Here is a working patch for the same.

marcingy , I would like to know if it would be worth spending some time to create a patch which would enable the user to select between normal behavior as well as extended ( the one that this patch aims at ) behavior just like the Logout action can select between different api version?

For others following this issue you may be interested in the following initiative.

User Login with E-Mail Address Resource for the Services Module
is an issue in LoginToboggan which aims for similar functionality. But as i had said earlier, creating a different module / resource for this change is an overkill.

d34dman’s picture

sorry for being rude, i didn't find that there was already a issue which was created earlier for the same purpose...

Click here to visit the old Issue.

kylebrowning’s picture

I dont think its work time putting this into core, because you can easily override the login method and allow users to login with email. Services goal has always been to provide what is only in Drupal core.

marcingy’s picture

This won't go into services which is why I marked it won't fix :)

joelstein’s picture

Issue summary: View changes

In case this helps somebody, you can do this by changing the argument on its way in to Services:

/**
 * Implements hook_services_request_preprocess_alter() from Services.
 */
function mymodule_services_request_preprocess_alter($controller, &$args, $options) {
  if ($controller['callback'] == '_user_resource_login') {
    $name = db_query("SELECT name FROM {users} WHERE LOWER(mail) = LOWER(:mail)", array(
      ':mail' => $args[0]
    ))->fetchField();
    if (!empty($name)) {
      $args[0] = $name;
    }
  }
}