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

Load user email in LinkedIn provider #191

Merged
merged 5 commits into from
Jun 16, 2019
Merged

Conversation

JakubSzajna
Copy link
Contributor

As per https://github.com/Sorcery/sorcery/blob/master/lib/generators/sorcery/templates/migration/core.rb user email is a mandatory field in the DB. Thus, the recent fix for LinkedIn provider will produce an error when you try to register a new profile with it.

This fix loads user email from the additional endpoint in LinkedIn API v2 following this description: https://docs.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/sign-in-with-linkedin?context=linkedin/consumer/context#retrieving-member-email-address

@chhlga
Copy link
Contributor

chhlga commented May 28, 2019

Do we have enough specs to test this case?

@joshbuker
Copy link
Member

@chhga unfortunately we don't have reliable specs for any of the OAuth providers. I don't know that it's worth the dev-time to develop it however, as the plan is to switch to Omniauth at some point. That being said, I wouldn't be opposed if someone wanted to put the time into creating specs. We can definitely use more coverage.

Copy link
Member

@joshbuker joshbuker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that this doesn't conditionally check for the r_emailaddress scope, and will always hit the email url. This could have unintended consequences for apps that only use r_liteprofile.

lib/sorcery/providers/linkedin.rb Show resolved Hide resolved
joshbuker
joshbuker previously approved these changes Jun 5, 2019
Copy link
Member

@joshbuker joshbuker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm tempted to change the comment inside the initializer, but the code itself looks good to go.

I'll add the changelog and tweak the wording a little bit in the initializer before merging.

lib/generators/sorcery/templates/initializer.rb Outdated Show resolved Hide resolved
lib/sorcery/providers/linkedin.rb Show resolved Hide resolved
lib/sorcery/providers/linkedin.rb Show resolved Hide resolved
@joshbuker
Copy link
Member

Thank you @JakubSzajna for your work on this! Merging.

@joshbuker joshbuker merged commit 4bda5a8 into Sorcery:master Jun 16, 2019
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

Successfully merging this pull request may close these issues.

3 participants