Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add field on Auth endpoint for email or username from single input #19

Open
mikeybinns opened this issue Dec 21, 2021 · 7 comments
Open
Labels
feature-request New feature or request

Comments

@mikeybinns
Copy link

Is your feature request related to a problem?

WordPress login forms allow users to enter either a username or email address in the same field for logging in, but this plugin makes you have to determine whether a field is a username or email address before it's sent to the auth endpoint. The only effective way to tell this is in the WP admin by seeing if a user exists, as usernames allow @ and . even in strict mode.

Describe the solution you'd like

An optional field added to the auth endpoint called username_or_email. If the auth endpoint is called with this parameter, it should try to find a user by username and if it doesn't exist, try to find the user by email address instead, and if fails both, then throw an error.
You can use the get_user_by function to achieve this.

I don't have time to work on this myself at the moment, but I can probably submit a pull request for this in a couple of months if you don't have time to work on this yourself.

@cheesegrits
Copy link

+1 for this.

@IRediTOTO
Copy link

You can take this field from jwt, let's decode it

@mikeybinns
Copy link
Author

You can take this field from jwt, let's decode it

This is on the auth endpoint, so at this point, you haven't received a JWT from the site for you to decode the payload and retrieve the data from.

@canonex
Copy link
Contributor

canonex commented Jan 10, 2022

You can take this field from jwt, let's decode it

How should you decode the Jwt?
Is there a public function ready to use?
Thank you.

@mikeybinns
Copy link
Author

How should you decode the Jwt?
Is there a public function ready to use?

You would decode this the same as any other endpoint.

If you're having trouble with this, you should open a new issue, as this is not related to this issue.

@true2thepen
Copy link
Contributor

Would it not be better to check in the current endpoint as is whether the user passed an email or username via the username field? This would, IMHO, be better than adding another field.

@true2thepen
Copy link
Contributor

@nicumicle I have created a patch to allow the username field to contain either the username or email for the /auth endpoint. I have tested it on my local dev server and found no problems. This will allow the username field to behave in the same way as the username input on the Standard WP login.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants