Skip to content

Commit

Permalink
Ask for users.profile:read.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Aug 20, 2017
1 parent 654af30 commit 3a497b4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
14 changes: 7 additions & 7 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-08-19 19:16:02 -0400 using RuboCop version 0.49.1.
# on 2017-08-20 14:29:34 -0400 using RuboCop version 0.49.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -19,31 +19,31 @@ Lint/EndAlignment:
Exclude:
- 'slack-sup/models/team.rb'

# Offense count: 13
# Offense count: 14
Metrics/AbcSize:
Max: 40

# Offense count: 49
# Offense count: 52
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 162

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 125
Max: 126

# Offense count: 5
Metrics/CyclomaticComplexity:
Max: 11

# Offense count: 215
# Offense count: 244
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 256

# Offense count: 10
# Offense count: 11
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 31
Expand All @@ -52,7 +52,7 @@ Metrics/MethodLength:
Metrics/PerceivedComplexity:
Max: 11

# Offense count: 31
# Offense count: 40
Style/Documentation:
Enabled: false

Expand Down
2 changes: 1 addition & 1 deletion public/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
</a>
<div class="row spacer"></div>
<div class="row text-center services-text-color">
<a class="add-to-slack" href="https://slack.com/oauth/authorize?scope=bot&amp;client_id=<%= ENV['SLACK_CLIENT_ID'] %>"><img alt="Add S'Up to Slack" height="40" width="139" src="https://platform.slack-edge.com/img/add_to_slack.png" srcset="https://platform.slack-edge.com/img/add_to_slack.png 1x, https://platform.slack-edge.com/img/add_to_slack@2x.png 2x"></a>
<a class="add-to-slack" href="https://slack.com/oauth/authorize?scope=bot,users.profile:read&amp;client_id=<%= ENV['SLACK_CLIENT_ID'] %>"><img alt="Add S'Up to Slack" height="40" width="139" src="https://platform.slack-edge.com/img/add_to_slack.png" srcset="https://platform.slack-edge.com/img/add_to_slack.png 1x, https://platform.slack-edge.com/img/add_to_slack@2x.png 2x"></a>
</div>
<div class="row text-center small">
<br>Try free for two weeks, no credit card required, $39.99/yr subscription after that.
Expand Down
8 changes: 6 additions & 2 deletions slack-sup/api/endpoints/teams_endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,20 @@ class TeamsEndpoint < Grape::API
code: params[:code]
)

access_token = rc['access_token']
team = Team.where(access_token: access_token).first

token = rc['bot']['bot_access_token']
team = Team.where(token: token).first
team ||= Team.where(token: token).first
team ||= Team.where(team_id: rc['team_id']).first
if team && !team.active?
team.activate!(token)
team.update_attributes!(active: true, token: token, access_token: access_token)
elsif team
raise "Team #{team.name} is already registered."
else
team = Team.create!(
token: token,
access_token: access_token,
team_id: rc['team_id'],
name: rc['team_name']
)
Expand Down
3 changes: 3 additions & 0 deletions slack-sup/models/team.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class Team
# non-bot access token
field :access_token, type: String

# enable API for this team
field :api, type: Boolean, default: false

Expand Down
2 changes: 1 addition & 1 deletion spec/integration/teams_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
expect(title).to eq("S'Up for Slack Teams")
end
it 'includes a link to add to slack with the client id' do
expect(find("a[href='https://slack.com/oauth/authorize?scope=bot&client_id=#{ENV['SLACK_CLIENT_ID']}']"))
expect(find("a[href='https://slack.com/oauth/authorize?scope=bot,users.profile:read&client_id=#{ENV['SLACK_CLIENT_ID']}']"))
end
end
end

0 comments on commit 3a497b4

Please sign in to comment.