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.11 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.10 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.9 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.8 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.7 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.6 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.5 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.4 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.3 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.2 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.1 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.32 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.31 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.30 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.29 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.28 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.27 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.26 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.25 app/controllers/iugu/omniauth_callbacks_controller.rb
iugusdk-1.0.0.alpha.24 app/controllers/iugu/omniauth_callbacks_controller.rb