Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/omniauth/strategies/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def authorize_params
{
'nickname' => raw_info['login'],
'email' => email,
'email_verified' => @email_verified || false,
Copy link
Author

Choose a reason for hiding this comment

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

This causes nil values to be changed into false.

Choose a reason for hiding this comment

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

usual approach is !!(something)

'display_email' => raw_info['email'],
'name' => raw_info['name'],
'image' => raw_info['avatar_url'],
'urls' => {
Expand All @@ -39,7 +41,7 @@ def authorize_params
end

extra do
{:raw_info => raw_info}
{:raw_info => raw_info, :all_emails => emails}
end

def raw_info
Expand All @@ -48,12 +50,16 @@ def raw_info
end

def email
(email_access_allowed?) ? primary_email : raw_info['email']
(email_access_allowed?) ? primary_email : raw_info['email']
end

def primary_email
primary = emails.find{|i| i['primary'] }
primary && primary['email'] || emails.first && emails.first['email']
primary = emails.find { |i| i['primary'] }
if primary && primary['email']
@email_verified = primary['verified']
return primary['email']
end
emails.first && emails.first['email']
end

# The new /user/emails API - http://developer.github.com/v3/users/emails/#future-response
Expand Down