Sha256: 4944a27068950fb22a82810ad76c1cbdeffd1e3296ef7776d70e1123024a413d

Contents?: true

Size: 1.16 KB

Versions: 34

Compression:

Stored size: 1.16 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"])
        flash[:group] = :social
        redirect_to((env["omniauth.origin"] || root_path ) + "#social", notice: I18n.t("iugu.social_linked"))
      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 ) + "#social"
        else
          redirect_to (env["omniauth.origin"] || root_path ) + "#social", :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

34 entries across 34 versions & 1 rubygems

Version Path
iugusdk-1.0.0.alpha.23 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.22 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.21 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.20 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.19 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.18 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.17 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.16 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.14 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.13 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.12 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.11 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.10 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.9 app/controllers/iugu/omniauth_callbacks_controller.rb