Permalink
Browse files

use private email address if public is empty

  • Loading branch information...
1 parent 10397b7 commit 91c4f4bb7f8d2f2559920a0cd7bfbc11450a8776 @benoist benoist committed May 30, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 lib/omniauth/strategies/github.rb
@@ -18,7 +18,7 @@ def request_phase
info do
{
'nickname' => raw_info['login'],
- 'email' => raw_info['email'],
+ 'email' => email,
'name' => raw_info['name'],
'image' => raw_info['avatar_url'],
'urls' => {
@@ -36,6 +36,15 @@ def raw_info
access_token.options[:mode] = :query
@raw_info ||= access_token.get('/user').parsed
end
+
+ def email
+ raw_info['email'] || emails.first
+ end
+
+ def emails
+ access_token.options[:mode] = :query
+ @emails ||= access_token.get('/user/emails').parsed
+ end
end
end
end

0 comments on commit 91c4f4b

Please sign in to comment.