Installed gems omniauth-facebook and omniauth-google-oauth2, setted it in devise config and added to user fields provider and uid
diff --git a/Gemfile b/Gemfile
index 2c069b6..591d160 100644
--- a/Gemfile
+++ b/Gemfile
@@ -7,6 +7,8 @@
gem 'puma'
gem 'devise'
+gem 'omniauth-facebook'
+gem 'omniauth-google-oauth2'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
diff --git a/Gemfile.lock b/Gemfile.lock
index fba6fe9..5bb659d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -88,8 +88,11 @@
railties (>= 3.0.0)
faker (1.4.3)
i18n (~> 0.5)
+ faraday (0.9.1)
+ multipart-post (>= 1.2, < 3)
globalid (0.3.5)
activesupport (>= 4.1.0)
+ hashie (3.4.2)
headless (2.1.0)
i18n (0.7.0)
jbuilder (2.2.16)
@@ -100,6 +103,7 @@
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
+ jwt (1.5.0)
launchy (2.4.3)
addressable (~> 2.3)
loofah (2.0.2)
@@ -110,8 +114,27 @@
mini_portile (0.6.2)
minitest (5.7.0)
multi_json (1.11.0)
+ multi_xml (0.5.5)
+ multipart-post (2.0.0)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
+ 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-google-oauth2 (0.2.6)
+ omniauth (> 1.0)
+ omniauth-oauth2 (~> 1.1)
+ omniauth-oauth2 (1.3.0)
+ oauth2 (~> 1.0)
+ omniauth (~> 1.2)
orm_adapter (0.5.0)
pg (0.18.2)
puma (2.11.3)
@@ -234,6 +257,8 @@
headless
jbuilder (~> 2.0)
jquery-rails
+ omniauth-facebook
+ omniauth-google-oauth2
pg
puma
quiet_assets
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
index 7b3230a..ae8d4b8 100644
--- a/config/initializers/devise.rb
+++ b/config/initializers/devise.rb
@@ -233,12 +233,16 @@
# config.navigational_formats = ['*/*', :html]
# The default HTTP method used to sign out a resource. Default is :delete.
- config.sign_out_via = :delete
+ config.sign_out_via = :get
# ==> OmniAuth
# Add a new OmniAuth provider. Check the wiki for more information on setting
# up on your models and hooks.
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
+ require 'omniauth-facebook'
+ config.omniauth :facebook, ENV['FACEBOOK_CLIENT_ID'], ENV['FACEBOOK_CLIENT_SECRET']
+ require 'omniauth-google-oauth2'
+ config.omniauth :google_oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET']
# ==> Warden configuration
# If you want to use other strategies, that are not supported by Devise, or
diff --git a/db/migrate/20150610102232_add_columns_to_users.rb b/db/migrate/20150610102232_add_columns_to_users.rb
new file mode 100644
index 0000000..dec83f6
--- /dev/null
+++ b/db/migrate/20150610102232_add_columns_to_users.rb
@@ -0,0 +1,6 @@
+class AddColumnsToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :provider, :string
+ add_column :users, :uid, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index a62fc5c..78219e9 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20150603155333) do
+ActiveRecord::Schema.define(version: 20150610102232) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -31,6 +31,8 @@
t.inet "last_sign_in_ip"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.string "provider"
+ t.string "uid"
end
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree