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?
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | login_emailusername.zip | 11.74 KB | sunilkansodiya |
| #10 | 2910511-10-use-userauth-service.patch | 6.4 KB | mmbk |
| #9 | allow-rest-login-with-email-2910511-9.patch | 7.3 KB | grayle |
| #7 | allow-rest-login-with-email-2910511-7.patch | 4.9 KB | grayle |
Issue fork login_emailusername-2910511
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:
- 2910511-login-with-email
changes, plain diff MR !1
Comments
Comment #2
paurnimap commentedComment #3
paurnimap commentedComment #4
norman.lolComment #5
rjjakes commentedI 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.
Comment #6
norman.lolComment #7
grayle commentedIt'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.
Comment #8
grayle commentedComment #9
grayle commentedAdded new patch with support for resets
Comment #10
mmbkThe 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
Comment #11
Sherif Darwish commentedI 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.
Comment #12
manav commentedI 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.
Comment #13
manav commentedComment #14
hfm commentedWill this patch (#9) going to be implemented ?
Decoupled Drupal could really benefit from a mail login using REST.
Cordially.
Comment #15
sunilkansodiya commentedThe 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
Comment #16
kundu commented#15 did the trick!
Thank you¡¡
Comment #17
shaundychkoThis issue has been solved by the mail_login module. See #3160384: Deprecate in favour of mail_login.
Comment #21
rjjakes commentedReviewed and tested on D9.3. I'll go ahead and merge this and create a new release.