Sha256: 46fbb73cf55c56e90975a66c019770ce2742e115ed2302131a8428c2349ec438

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

class Iugu::OmniauthCallbacksController < Devise::OmniauthCallbacksController

  def action_missing(provider)
    # TODO: Improve this
    if !User.omniauth_providers.index(provider.to_sym).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
    else
      raise ActionController::RoutingError.new("Not found")
    end
  end
  
  def passthru
    render :status => 404, :text => "Not found. Authentication passthru.", :layout => false
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
iugusdk-1.0.0.alpha.7 app/controllers/iugu/omniauth_callbacks_controller.rb