Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ gem 'jbuilder', '~> 2.0'
gem 'jquery-rails'
gem 'kramdown'
gem 'materialize-sass'
gem 'omniauth-slack'
gem 'omniauth-slack', github: 'kmrshntr/omniauth-slack'
gem 'pg'
gem 'puma'
gem 'react-rails'
Expand Down
11 changes: 8 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ GIT
minitest-metadata (~> 0.6)
minitest-rails (= 3.0.0.rc1)

GIT
remote: git://github.com/kmrshntr/omniauth-slack.git
revision: 8b2371150cf3d892750695cd88118f8b16db9d01
specs:
omniauth-slack (2.3.0)
omniauth-oauth2 (~> 1.3.1)

GIT
remote: https://github.com/5t111111/tapp.git
revision: eba500b69d89a184d2382afe117a94a7ce562d37
Expand Down Expand Up @@ -158,8 +165,6 @@ GEM
omniauth-oauth2 (1.3.1)
oauth2 (~> 1.0)
omniauth (~> 1.2)
omniauth-slack (2.3.0)
omniauth-oauth2 (~> 1.3.1)
pg (0.18.4)
poltergeist (1.9.0)
capybara (~> 2.1)
Expand Down Expand Up @@ -299,7 +304,7 @@ DEPENDENCIES
materialize-sass
minitest-rails-capybara!
minitest-stub_any_instance
omniauth-slack
omniauth-slack!
pg
poltergeist
pry-byebug
Expand Down
5 changes: 4 additions & 1 deletion app/models/concerns/authenticator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ def team_member?(uid)
end

def fetch_member_uids
team_info = Slack::Web::Client.new.team_info
users_list = Slack::Web::Client.new.users_list
users_list.members.reject(&:deleted).map(&:id)
users_list.members.reject(&:deleted).map(&:id).map do |uid|
"#{uid}-#{team_info.team.id}"
end
end
end
end
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class User < ActiveRecord::Base
class << self
def find_or_create_from(auth)
find_or_create_by(provider: auth[:provider], uid: auth[:uid]) do |user|
user.nickname = auth[:info][:nickname]
user.nickname = auth[:info][:name]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/omniauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
provider :slack,
ENV['SLACK_CLIENT_ID'],
ENV['SLACK_CLIENT_SECRET'],
scope: 'identify'
scope: 'identity.basic'

on_failure { |env| OmniAuth::FailureEndpoint.new(env).redirect_to_failure }
end
5 changes: 5 additions & 0 deletions db/migrate/20160614083937_add_image_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddImageToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :image, :string
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160516050348) do
ActiveRecord::Schema.define(version: 20160614083937) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand All @@ -31,6 +31,7 @@
t.datetime "updated_at"
t.string "provider"
t.string "uid"
t.string "image"
end

add_foreign_key "posts", "users"
Expand Down