Class: OmniauthCallbacksController

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

Instance Method Summary collapse

Instance Method Details

#allObject Also known as: facebook, google_oauth2, lastfm



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/omniauth_callbacks_controller.rb', line 2

def all
  user = User.from_omniauth(request.env['omniauth.auth'])

  if user.persisted?
    kind = case request.env['omniauth.auth']['provider']
    when 'google_oauth2' then 'Google'
    else request.env['omniauth.auth']['provider'].titleize
    end
    
    flash[:notice] = I18n.t 'devise.omniauth_callbacks.success', kind: kind
     user, event: :authentication
  else
    session['devise.user_attributes'] = user.attributes
    redirect_to new_user_registration_url
  end
end