Sha256: be83ab348da741fba8f5c8681e13e5928bf98ca46629807de1e0dcc108b81168

Contents?: true

Size: 768 Bytes

Versions: 2

Compression:

Stored size: 768 Bytes

Contents

class Iugu::OmniauthCallbacksController < Devise::OmniauthCallbacksController

  def method_missing(provider)
    if !User.omniauth_providers.index(provider).nil?
      if current_user 
        current_user.find_or_create_social(env["omniauth.auth"])
        redirect_to after_sign_in_path_for( current_user )
      else
        if user = User.find_or_create_by_social(env["omniauth.auth"])
          select_account user
          sign_in user
          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

2 entries across 2 versions & 1 rubygems

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