Skip to content

Commit 1c57c79

Browse files
authored
Merge pull request #69 from almirsarajcic/bug-fixes/email-nil
Email without scope
2 parents 4ae530b + 04e99c7 commit 1c57c79

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/omniauth/strategies/github.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def authorize_params
2828
info do
2929
{
3030
'nickname' => raw_info['login'],
31-
'email' => primary_email,
31+
'email' => email,
3232
'name' => raw_info['name'],
3333
'image' => raw_info['avatar_url'],
3434
'urls' => {

spec/omniauth/strategies/github_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@
135135
end
136136
end
137137

138+
context '#info.email' do
139+
it 'should use any available email' do
140+
allow(subject).to receive(:raw_info).and_return({})
141+
allow(subject).to receive(:email).and_return('[email protected]')
142+
expect(subject.info['email']).to eq('[email protected]')
143+
end
144+
end
145+
138146
context '#info.urls' do
139147
it 'should use html_url from raw_info' do
140148
allow(subject).to receive(:raw_info).and_return({ 'login' => 'me', 'html_url' => 'http://enterprise/me' })

0 commit comments

Comments
 (0)