Sha256: 78ba4dca5152e21a47fb9f55a6b1742b98eb0c70d42c89f5cb0075a620eb8496

Contents?: true

Size: 778 Bytes

Versions: 1

Compression:

Stored size: 778 Bytes

Contents

class OmniauthCallbacksController < Devise::OmniauthCallbacksController
  
  def facebook
    woodlock_oauth_callback('facebook')  
  end

  def google_oauth2
    woodlock_oauth_callback('google')
  end

  private

  def woodlock_oauth_callback(kind)
    # debug omniauth hash
    # render :text => "<pre>" + env["omniauth.auth"].to_yaml and return
    @user = User.find_or_create_with_oauth(request.env['omniauth.auth'])      

    if @user.persisted?       
      sign_in_and_redirect @user, event: :authentication # this will throw if @user is not activated
      set_flash_message(:notice, :success, kind: kind.titleize) if is_navigational_format?
    else
      session['devise.#{kind}_data'] = request.env['omniauth.auth']
      redirect_to sign_in_url
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
woodlock-0.0.1 app/controllers/omniauth_callbacks_controller.rb