Skip to content

Commit 267d6f1

Browse files
committed
Merge branch '8012labs-bot-info'
2 parents ac24907 + c3ed6eb commit 267d6f1

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/omniauth/strategies/slack.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ class Slack < OmniAuth::Strategies::OAuth2
5353
extra do
5454
hash = {
5555
raw_info: raw_info,
56-
web_hook_info: web_hook_info
56+
web_hook_info: web_hook_info,
57+
bot_info: bot_info
5758
}
5859

5960
unless skip_info?
@@ -87,12 +88,24 @@ def web_hook_info
8788
access_token.params['incoming_webhook']
8889
end
8990

91+
def bot_info
92+
return {} unless bot_allowed?
93+
access_token.params['bot']
94+
end
95+
9096
def incoming_webhook_allowed?
9197
return false unless options['scope']
9298
webhooks_scopes = ['incoming-webhook']
9399
scopes = options['scope'].split(',')
94100
(scopes & webhooks_scopes).any?
95101
end
102+
103+
def bot_allowed?
104+
return false unless options['scope']
105+
bot_scopes = ['bot']
106+
scopes = options['scope'].split(',')
107+
(scopes & bot_scopes).any?
108+
end
96109
end
97110
end
98111
end

test/test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class SkipInfoTest < StrategyTestCase
134134
@options = { skip_info: true }
135135
strategy.stubs(:raw_info).returns({})
136136
strategy.stubs(:webhook_info).returns({})
137-
assert_equal %w[raw_info web_hook_info], strategy.extra.keys.map(&:to_s)
137+
assert_equal %w[raw_info web_hook_info bot_info], strategy.extra.keys.map(&:to_s)
138138
end
139139

140140
end

0 commit comments

Comments
 (0)