Sha256: fc657a210ed2b6925374867caca60fac491a2c236c8be2f421f989b0dcdd74c9

Contents?: true

Size: 1.67 KB

Versions: 5

Compression:

Stored size: 1.67 KB

Contents

require "social_auth/engine"
require 'sidekiq'

module SocialAuth
  extend ActiveSupport::Autoload

  autoload :ActsAsSocialUser, 'social_auth/acts_as_social_user'

  mattr_accessor :redis_instance_method
  @@redis_instance_method = nil

  mattr_accessor :twitter_consumer_key
  @@twitter_consumer_key = nil

  mattr_accessor :twitter_consumer_secret
  @@twitter_consumer_secret = nil

  mattr_accessor :google_client_id
  @@google_client_id = nil

  mattr_accessor :google_client_secret
  @@google_client_secret = nil

  mattr_accessor :google_redirect_uri
  @@google_redirect_uri = nil

  mattr_accessor :google_api_key
  @@google_api_key = nil

  # Used to set up Social Login from the initializer.
  def self.setup
    yield self
  end

  def self.authenticate(type, auth_token)
    case type.camelize
    when "Facebook"
      FacebookService.init_with(auth_token)
    when "Twitter"
      TwitterService.init_with(auth_token)
    when "GooglePlus"
      GooglePlusService.init_with(auth_token)
    end
  end

  def self.connect(user, type, auth_token, method="Connected")
    case type.camelize
    when "Facebook"
      FacebookService.connect_with(user, auth_token, method)
    when "Twitter"
      TwitterService.connect_with(user, auth_token, method)
    when "GooglePlus"
      GooglePlusService.connect_with(user, auth_token, method)
    end
  end

  def self.disconnect(user, type)
    case type.camelize
    when "Facebook"
      FacebookService.disconnect_user(user)
    when "Twitter"
      TwitterService.disconnect_user(user)
    when "GooglePlus"
      GooglePlusService.disconnect_user(user)
    end
  end
end

module ActiveRecord
  class Base
    include SocialAuth::ActsAsSocialUser
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
social_auth-0.0.13 lib/social_auth.rb
social_auth-0.0.12 lib/social_auth.rb
social_auth-0.0.11 lib/social_auth.rb
social_auth-0.0.10 lib/social_auth.rb
social_auth-0.0.9 lib/social_auth.rb