Sha256: df8a3e3b5053d8d7845289bb286d6b3b8856f307c08452f52196b697e2036042

Contents?: true

Size: 959 Bytes

Versions: 3

Compression:

Stored size: 959 Bytes

Contents

class Iugu::OmniauthCallbacksController < Devise::OmniauthCallbacksController

  def method_missing(provider)
    if !User.omniauth_providers.index(provider).nil?
      if current_user 
        raise ActionController::RoutingError.new("Not found") unless IuguSDK::enable_social_linking
        current_user.find_or_create_social(env["omniauth.auth"])
        redirect_to(env["omniauth.origin"] || root_path)
      else
        raise ActionController::RoutingError.new("Not found") unless IuguSDK::enable_social_login
        if user = User.find_or_create_by_social(env["omniauth.auth"])
          sign_in user
          select_account
          redirect_to after_sign_in_path_for( user )
        else
          redirect_to (env["omniauth.origin"] || root_path), :notice => I18n.t('errors.messages.email_already_in_use')
        end 
      end
    end
  end
  
  def passthru
    render :status => 404, :text => "Not found. Authentication passthru."
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
iugusdk-1.0.0.alpha.5 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.4 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.3 app/controllers/iugu/omniauth_callbacks_controller.rb