Sha256: c4704f494578fe8cdb705d9011ebfa8dbb897c584760c185ba3784c59db20d5e

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module RedBase
  module Omniauth

    class CallBacks

      if Devise.omniauth_configs.any?
        Devise.omniauth_configs.keys.each do |provider|
          unless defined? provider
            puts ">>>>>>>>>>>>>>>>>>>>>>> method not define"
            define_method(provider) {default_service_callback}
          end
        end
      end


      def facebook

        create_or_find_user

        if @user.persisted?
          sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
          set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format?
        else
          session["devise.facebook_data"] = request.env["omniauth.auth"]
          redirect_to new_user_registration_url
        end
      end


      def default_service_callback
        puts ">>>>>> ", params
      end


      private

      def create_or_find_user
        # This method is implemented in User model
        @user = User.find_from_oauth(request.env["omniauth.auth"], current_user)
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
red_base-0.6.0 lib/red_base/omniauth/callbacks.rb~