Tutorial by Examples

Modify your Gemfile to include the Devise gem: gem 'devise' Then update your gems with: $ bundle install Run the installers in your project: $ rails generate devise:install Then create your Devise model (e.g. User) with: $ rails generate devise User you'll need to set up the default ...
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController include OmniConcern %w[facebook twitter gplus linkedin].each do |meth| define_method(meth) do create end end end Note: In the part “%w[facebook twitter gplus linkedin]”, you should list ...
module OmniConcern extend ActiveSupport::Concern def create auth_params = request.env["omniauth.auth"] provider = AuthenticationProvider.get_provider_name(auth_params.try(:provider)).first authentication = provider.user_authentications.where(uid: auth_params.uid).first...
class CreateAuthenticationProviders < ActiveRecord::Migration def change create_table "authentication_providers", :force => true do |t| t.string "name" t.datetime "created_at", :null => false ...
class CreateUserAuthentications < ActiveRecord::Migration def change create_table "user_authentications", :force => true do |t| t.integer "user_id" t.integer "authentication_provider_id" t.string "uid&q...
belongs_to :user belongs_to :authentication_provider serialize :params def self.create_from_omniauth(params, user, provider) token_expires_at = params['credentials']['expires_at'] ? Time.at(params['credentials']['expires_at']).to_datetime : nil create( user: user, ...
include OmniauthAttributesConcern has_many :user_authentications devise :omniauthable, :database_authenticatable, :registerable,:recoverable, :rememberable, :trackable def self.create_from_omniauth(params) self.send(params.provider,params) end
module OmniauthAttributesConcern extend ActiveSupport::Concern module ClassMethods Add Methods here end end In this concern we can create methods for each social media to fetch and store attributes. def twitter params (params['info']['email'] = "dummy#{SecureRan...
devise_for :users, controllers: {omniauth_callbacks: 'users/omniauth_callbacks'}
For Facebook config.omniauth :facebook, facebook_app_id, facebook_secret_key, :display => "popup", :scope => 'email,publish_actions', info_fields: 'email,name' For Twitter config.omniauth :twitter, twitter_app_id, twitter_secret_key, :display => "popup", :scope =&gt...
gem 'omniauth-oauth2' , '~> 1.3.1' gem 'omniauth' gem 'omniauth-facebook' gem 'omniauth-twitter' gem 'omniauth-gplus' gem 'omniauth-linkedin' Run the bundle install command, restart your server and off you go!

Page 1 of 1