diff --git a/lib/omniauth/strategies/github.rb b/lib/omniauth/strategies/github.rb index be08d26..26d31e7 100644 --- a/lib/omniauth/strategies/github.rb +++ b/lib/omniauth/strategies/github.rb @@ -28,7 +28,7 @@ def authorize_params info do { 'nickname' => raw_info['login'], - 'email' => primary_email, + 'email' => email, 'name' => raw_info['name'], 'image' => raw_info['avatar_url'], 'urls' => { diff --git a/spec/omniauth/strategies/github_spec.rb b/spec/omniauth/strategies/github_spec.rb index 6afa675..0d4c313 100644 --- a/spec/omniauth/strategies/github_spec.rb +++ b/spec/omniauth/strategies/github_spec.rb @@ -135,6 +135,14 @@ end end + context '#info.email' do + it 'should use any available email' do + allow(subject).to receive(:raw_info).and_return({}) + allow(subject).to receive(:email).and_return('you@example.com') + expect(subject.info['email']).to eq('you@example.com') + end + end + context '#info.urls' do it 'should use html_url from raw_info' do allow(subject).to receive(:raw_info).and_return({ 'login' => 'me', 'html_url' => 'http://enterprise/me' })