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

Unable to match previous users by email #52

Open
Xtremefaith opened this issue Aug 31, 2016 · 5 comments
Open

Unable to match previous users by email #52

Xtremefaith opened this issue Aug 31, 2016 · 5 comments

Comments

@Xtremefaith
Copy link

Xtremefaith commented Aug 31, 2016

See original thread for backstory. but so far I have determined that up until this point it was intentional to not capture emails in the $oauth_identity variable, but unfortunately that means without it there is no way to match the authenticated user with an existing account by email.

Is this a feature you do not wish to have within WP-OAuth? If it is something you're willing to include I can add it today and send a PR. Let me know, thanks!

@Xtremefaith
Copy link
Author

I just came across #3 and realize some of the reasoning behind this feature better. For my current purposes, I need this feature for internal websites so the security vulnerabilities are less of an issue to me. I've currently got this working perfectly but I will also build in a setting that allows the site admin the ability to disable this feature.

Xtremefaith added a commit to Xtremefaith/WP-OAuth that referenced this issue Aug 31, 2016
Xtremefaith added a commit to Xtremefaith/WP-OAuth that referenced this issue Aug 31, 2016
Xtremefaith added a commit to Xtremefaith/WP-OAuth that referenced this issue Aug 31, 2016
@kylewhenderson
Copy link

Was looking for the same solution - is this a fork of the existing plugin?

@Xtremefaith
Copy link
Author

Yes I forked it and added my solution along with a few other updates. I thought I would maintain it more but I've since begun writing another solution that better follows OOP. Because of some work deadlines I won't be able to make that public until Jan sometime. But you're free to use what I started here it follows suit with the original author's work, I just personally don't like how procedural he implements each provider.

@kylewhenderson
Copy link

Would your version automatically populate the user's name and email address (maybe username) into the WordPress user profile? New to OAuth so I probably have some fundamental misunderstandings of how it works, but creating an automatic username of 'user4' etc didn't seem like a good solution especially since WordPress doesn't allow for users to change their username.

@Xtremefaith
Copy link
Author

So each provider file (i.e. login-google.php) has the following methods setup:

  • get_oauth_code()
  • get_oauth_token()
  • get_oauth_identity()

In the identity method you can parse out the details given from the provider. This depends on the provider and the scope that you request. will need to look up each provider and configure respectively.

After that, the $oauth_identity should have what it needs to map to the WP_User details that you're looking for (see wp-oauth.php specifically the wpoa_login_user() method).

That should help you figure somethings out. The original author wanted to only request the bare minimum so I don't think he has intentions of setting it up to do much more, (at least not without options to allow the site admin to determine those things).

I'm pretty familiar with process so let me know if you have any questions. As I said, his implementation is pretty messy so personally I'm working on a better implementation of it right now. I could perhaps make that public soon if you want to contribute to that solution instead.

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

No branches or pull requests

2 participants