diff --git a/Gemfile b/Gemfile index 95ce82135..6365cc67f 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,7 @@ gem 'devise' # gem 'bcrypt', '~> 3.1.7' gem 'omniauth' gem 'omniauth-twitter' -# gem 'omniauth-facebook' +gem 'omniauth-facebook' # gem 'omniauth-google-oauth2' gem 'kaminari' diff --git a/Gemfile.lock b/Gemfile.lock index d1a5ece7b..0023fb231 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -133,6 +133,8 @@ GEM factory_girl_rails (4.5.0) factory_girl (~> 4.5.0) railties (>= 3.0.0) + faraday (0.9.1) + multipart-post (>= 1.2, < 3) foundation-rails (5.5.2.1) railties (>= 3.1.0) sass (>= 3.3.0, < 3.5) @@ -170,6 +172,7 @@ GEM railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (1.8.3) + jwt (1.5.1) kaminari (0.16.3) actionpack (>= 3.0.0) activesupport (>= 3.0.0) @@ -190,6 +193,8 @@ GEM mini_portile (0.6.2) minitest (5.8.0) multi_json (1.11.2) + multi_xml (0.5.5) + multipart-post (2.0.0) net-scp (1.2.1) net-ssh (>= 2.6.5) net-ssh (2.9.2) @@ -197,12 +202,23 @@ GEM nokogiri (1.6.6.2) mini_portile (~> 0.6.0) oauth (0.4.7) + oauth2 (1.0.0) + faraday (>= 0.8, < 0.10) + jwt (~> 1.0) + multi_json (~> 1.3) + multi_xml (~> 0.5) + rack (~> 1.2) omniauth (1.2.2) hashie (>= 1.2, < 4) rack (~> 1.0) + omniauth-facebook (2.0.1) + omniauth-oauth2 (~> 1.2) omniauth-oauth (1.1.0) oauth omniauth (~> 1.0) + omniauth-oauth2 (1.3.1) + oauth2 (~> 1.0) + omniauth (~> 1.2) omniauth-twitter (1.2.1) json (~> 1.3) omniauth-oauth (~> 1.1) @@ -374,6 +390,7 @@ DEPENDENCIES launchy letter_opener_web (~> 1.3.0) omniauth + omniauth-facebook omniauth-twitter paranoia pg diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index aac6583d1..a0a90c400 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -16,7 +16,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController end # [:twitter, :facebook, :google_oauth2].each do |provider| - [:twitter].each do |provider| + [:twitter, :facebook].each do |provider| provides_callback_for provider end diff --git a/app/views/devise/_omniauth_form.html.erb b/app/views/devise/_omniauth_form.html.erb index 888a3ba2f..cf06d359f 100644 --- a/app/views/devise/_omniauth_form.html.erb +++ b/app/views/devise/_omniauth_form.html.erb @@ -1,5 +1,6 @@
<%= link_to t("omniauth.twitter.sign_in"), user_omniauth_authorize_path(:twitter), class: 'button radius expand' %> +<%= link_to t("omniauth.facebook.sign_in"), user_omniauth_authorize_path(:facebook), class: 'button radius expand' %>
diff --git a/config/deploy/shared/secrets.yml.erb b/config/deploy/shared/secrets.yml.erb index 9a6582afb..b4fa2634f 100644 --- a/config/deploy/shared/secrets.yml.erb +++ b/config/deploy/shared/secrets.yml.erb @@ -4,5 +4,6 @@ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> twitter_key: <%= ENV["TWITTER_KEY"] %> twitter_secret: <%= ENV["TWITTER_SECRET"] %> + facebook_key: <%= ENV["FACEBOOK_KEY"] %> + facebook_secret: <%= ENV["FACEBOOK_SECRET"] %> server_name: <%= fetch(:server_name) %> - diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 06c4740ba..eb7ec1970 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -240,6 +240,7 @@ Devise.setup do |config| # up on your models and hooks. # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' config.omniauth :twitter, Rails.application.secrets.twitter_key, Rails.application.secrets.twitter_secret + config.omniauth :facebook, Rails.application.secrets.facebook_key, Rails.application.secrets.facebook_secret # ==> Warden configuration # If you want to use other strategies, that are not supported by Devise, or diff --git a/config/locales/en.yml b/config/locales/en.yml index 11f012080..15275eb82 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -153,3 +153,5 @@ en: title: Add Email twitter: sign_in: Sign in with Twitter + facebook: + sign_in: Sign in with Facebook diff --git a/config/locales/es.yml b/config/locales/es.yml index 2a5ee2ec5..74fd1d2d1 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -152,4 +152,6 @@ es: finish_signup: title: Añade tu email twitter: - sign_in: Inicia sessión con Twitter + sign_in: Entra con Twitter + facebook: + sign_in: Entra con Facebook diff --git a/config/secrets.yml.example b/config/secrets.yml.example index 72c7a6d64..fc872bdaa 100644 --- a/config/secrets.yml.example +++ b/config/secrets.yml.example @@ -16,16 +16,22 @@ development: secret_key_base: 56792feef405a59b18ea7db57b4777e855103882b926413d4afdfb8c0ea8aa86ea6649da4e729c5f5ae324c0ab9338f789174cf48c544173bc18fdc3b14262e4 twitter_key: AAAA twitter_secret: BBBB + facebook_key: AAAA + facebook_secret: BBBB <<: *default test: secret_key_base: 4d5adf961ddd27aef19622d6c0b3234d555f9ee003f022b1f829c92bbe33aaee907be7feb67bd54c14a1a32512fa968565ad405971fbc41bd0797af73c26a796 twitter_key: AAAA twitter_secret: BBBB + facebook_key: AAAA + facebook_secret: BBBB <<: *default production: secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> twitter_key: <%= ENV["TWITTER_KEY"] %> twitter_secret: <%= ENV["TWITTER_SECRET"] %> + facebook_key: <%= ENV["FACEBOOK_KEY"] %> + facebook_secret: <%= ENV["FACEBOOK_SECRET"] %> <<: *default