Skip to content

Commit 8589e2d

Browse files
committed
Merge pull request #19 from cavalle/emails
Only the user scope allows access to emails
2 parents d8da8b0 + cce737d commit 8589e2d

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/omniauth/strategies/github.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def emails
6262
end
6363

6464
def email_access_allowed?
65-
options['scope'] && !(options['scope'] == 'public')
65+
options['scope'] =~ /user/
6666
end
6767

6868
end

spec/omniauth/strategies/github_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,24 @@
2525
subject.should_not be_email_access_allowed
2626
end
2727

28-
it "should not allow email if scope is 'public'" do
29-
subject.options['scope'] = 'public'
30-
subject.should_not be_email_access_allowed
31-
end
32-
3328
it "should allow email if scope is user" do
3429
subject.options['scope'] = 'user'
3530
subject.should be_email_access_allowed
3631
end
3732

38-
it "should allow email if scope is scope is a bunch of stuff" do
39-
subject.options['scope'] = 'user,public_repo,repo,delete_repo,gist'
33+
it "should allow email if scope is a bunch of stuff including user" do
34+
subject.options['scope'] = 'public_repo,user,repo,delete_repo,gist'
4035
subject.should be_email_access_allowed
4136
end
4237

43-
it "should assume email access allowed if scope is scope is something currently not documented " do
38+
it "should not allow email if scope is other than user" do
39+
subject.options['scope'] = 'repo'
40+
subject.should_not be_email_access_allowed
41+
end
42+
43+
it "should assume email access not allowed if scope is something currently not documented " do
4444
subject.options['scope'] = 'currently_not_documented'
45-
subject.should be_email_access_allowed
45+
subject.should_not be_email_access_allowed
4646
end
4747
end
4848

0 commit comments

Comments
 (0)