Skip to content

Commit 452edb8

Browse files
committed
WIP
1 parent 9a0f72d commit 452edb8

7 files changed

Lines changed: 22 additions & 8 deletions

File tree

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ gem 'jbuilder', '~> 2.0'
1111
gem 'jquery-rails'
1212
gem 'kramdown'
1313
gem 'materialize-sass'
14-
gem 'omniauth-slack'
14+
gem 'omniauth-slack', github: 'kmrshntr/omniauth-slack'
1515
gem 'pg'
1616
gem 'puma'
1717
gem 'react-rails'

Gemfile.lock

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ GIT
88
minitest-metadata (~> 0.6)
99
minitest-rails (= 3.0.0.rc1)
1010

11+
GIT
12+
remote: git://github.com/kmrshntr/omniauth-slack.git
13+
revision: 8b2371150cf3d892750695cd88118f8b16db9d01
14+
specs:
15+
omniauth-slack (2.3.0)
16+
omniauth-oauth2 (~> 1.3.1)
17+
1118
GIT
1219
remote: https://github.com/5t111111/tapp.git
1320
revision: eba500b69d89a184d2382afe117a94a7ce562d37
@@ -158,8 +165,6 @@ GEM
158165
omniauth-oauth2 (1.3.1)
159166
oauth2 (~> 1.0)
160167
omniauth (~> 1.2)
161-
omniauth-slack (2.3.0)
162-
omniauth-oauth2 (~> 1.3.1)
163168
pg (0.18.4)
164169
poltergeist (1.9.0)
165170
capybara (~> 2.1)
@@ -299,7 +304,7 @@ DEPENDENCIES
299304
materialize-sass
300305
minitest-rails-capybara!
301306
minitest-stub_any_instance
302-
omniauth-slack
307+
omniauth-slack!
303308
pg
304309
poltergeist
305310
pry-byebug

app/models/concerns/authenticator.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ def team_member?(uid)
77
end
88

99
def fetch_member_uids
10+
team_info = Slack::Web::Client.new.team_info
1011
users_list = Slack::Web::Client.new.users_list
11-
users_list.members.reject(&:deleted).map(&:id)
12+
users_list.members.reject(&:deleted).map(&:id).map do |uid|
13+
"#{uid}-#{team_info.team.id}"
14+
end
1215
end
1316
end
1417
end

app/models/user.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class User < ActiveRecord::Base
66
class << self
77
def find_or_create_from(auth)
88
find_or_create_by(provider: auth[:provider], uid: auth[:uid]) do |user|
9-
user.nickname = auth[:info][:nickname]
9+
user.nickname = auth[:info][:name]
1010
end
1111
end
1212
end

config/initializers/omniauth.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
provider :slack,
33
ENV['SLACK_CLIENT_ID'],
44
ENV['SLACK_CLIENT_SECRET'],
5-
scope: 'identify'
5+
scope: 'identity.basic'
66

77
on_failure { |env| OmniAuth::FailureEndpoint.new(env).redirect_to_failure }
88
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddImageToUsers < ActiveRecord::Migration[5.0]
2+
def change
3+
add_column :users, :image, :string
4+
end
5+
end

db/schema.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended that you check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(version: 20160516050348) do
14+
ActiveRecord::Schema.define(version: 20160614083937) do
1515

1616
# These are extensions that must be enabled in order to support this database
1717
enable_extension "plpgsql"
@@ -31,6 +31,7 @@
3131
t.datetime "updated_at"
3232
t.string "provider"
3333
t.string "uid"
34+
t.string "image"
3435
end
3536

3637
add_foreign_key "posts", "users"

0 commit comments

Comments
 (0)