Does this module provide the support for rest, I want users to easily login into system with their email id or username with REST API, but it does not allow me to login with email id using JSON POST request.

Anyone can help me here?

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

paurnimap created an issue. See original summary.

paurnimap’s picture

Issue summary: View changes
paurnimap’s picture

Issue summary: View changes
norman.lol’s picture

Priority: Critical » Normal
rjjakes’s picture

I haven't tested with the REST authentication so it makes sense it doesn't work.
If you want to create a patch to enable that functionality, I'll happily review and merge.

norman.lol’s picture

Category: Support request » Feature request
grayle’s picture

It's a bit heavy-handed, but I couldn't set the POST data inside the Request object so I had to override the entire method. The only changes are line 47 to 55 in the new UserAuthenticationController.

Note: this won't work with any other modules that alter the user.login.http Route _controller. Only one will be victorious. And I haven't tested it with Json API, chances are they've got something custom going on there as well.

grayle’s picture

Status: Active » Needs review
grayle’s picture

Added new patch with support for resets

mmbk’s picture

StatusFileSize
new6.4 KB

The login part of patch #9 works fine ( I did not use an test the reset part yet).

The only thing where I'm not very happy with, is that the whole login method was copied for only a few changes. So I prepared a patch that introduces a 'UserAuth' Service, which will do the work. With this service we can rewrite the 'create'-method to use it (the service).
Using this overridden service the original 'login'-method will do accept emails as well.

There is still some duplicated code, but significant less compared to patch #7

Sherif Darwish’s picture

I do think the patch in #10 will skip the userIsBlocked validation which gets called before the userAuth service.

In addition, it may be better to carefully choose which module should hold this patch as it will not work in case another module override the login method like this one (https://www.drupal.org/project/rest_password)

We have the rest_password module in our site to allow REST end point for reset password. and they also override the login method.

manav’s picture

Assigned: Unassigned » manav

I have tested login part using rest of patch #9 and its works fine.

I also test patch #10 but its not working properly. Give Drupal default login error message.

manav’s picture

Assigned: manav » Unassigned
hfm’s picture

Will this patch (#9) going to be implemented ?
Decoupled Drupal could really benefit from a mail login using REST.
Cordially.

sunilkansodiya’s picture

StatusFileSize
new11.74 KB

The login part of patch #9 works fine in Default Login Rest API. Now it is working with Email and Username.

I have attached one contributed module and update according to patch #9.

Zip file name is 'login_emailusername.zip'.

Thanks to Grayle

kundu’s picture

#15 did the trick!
Thank you¡¡

shaundychko’s picture

This issue has been solved by the mail_login module. See #3160384: Deprecate in favour of mail_login.

  • mmbk authored 3e24588 on 8.x-1.x
    Issue #2910511 by Grayle, mmbk, rjjakes, sunilkansodiya, paurnimap,...

rjjakes’s picture

Status: Needs review » Fixed

Reviewed and tested on D9.3. I'll go ahead and merge this and create a new release.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.