Class: Iugu::OmniauthCallbacksController

Inherits:
Devise::OmniauthCallbacksController
  • Object
show all
Defined in:
app/controllers/iugu/omniauth_callbacks_controller.rb

Instance Method Summary collapse

Instance Method Details

#action_missing(provider) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/iugu/omniauth_callbacks_controller.rb', line 3

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::
      if user = User.find_or_create_by_social(env["omniauth.auth"])
         user
        
        redirect_to ( 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

#passthruObject



26
27
28
# File 'app/controllers/iugu/omniauth_callbacks_controller.rb', line 26

def passthru
  render :status => 404, :text => "Not found. Authentication passthru.", :layout => false
end