Class: Users::OmniauthCallbacksController

Inherits:
Devise::OmniauthCallbacksController
  • Object
show all
Defined in:
lib/generators/boring/oauth/facebook/install/templates/omniauth_callbacks_controller.rb,
lib/generators/boring/oauth/twitter/install/templates/omniauth_callbacks_controller.rb,
lib/generators/boring/oauth/google/install/templates/omniauth_callbacks_controller.rb,
lib/generators/boring/oauth/github/install/templates/omniauth_callbacks_controller.rb

Instance Method Summary collapse

Instance Method Details

#facebookObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/generators/boring/oauth/facebook/install/templates/omniauth_callbacks_controller.rb', line 5

def facebook
  # You need to implement the method below in your model (e.g. app/models/user.rb)
  @user = User.from_omniauth(request.env["omniauth.auth"])

  if @user.persisted?
     @user, event: :authentication #this will throw if @user is not activated
    set_flash_message(:notice, :success, kind: "Facebook") if is_navigational_format?
  else
    session["devise.facebook_data"] = request.env["omniauth.auth"].except(:extra) # Removing extra as it can overflow some session stores
    redirect_to new_user_registration_url
  end
end

#failureObject



18
19
20
# File 'lib/generators/boring/oauth/facebook/install/templates/omniauth_callbacks_controller.rb', line 18

def failure
  redirect_to root_path
end

#githubObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/generators/boring/oauth/github/install/templates/omniauth_callbacks_controller.rb', line 5

def github
  # You need to implement the method below in your model (e.g. app/models/user.rb)
  @user = User.from_omniauth(request.env["omniauth.auth"])

  if @user.persisted?
     @user, event: :authentication #this will throw if @user is not activated
    set_flash_message(:notice, :success, kind: "GitHub") if is_navigational_format?
  else
    session["devise.github_data"] = request.env["omniauth.auth"].except(:extra) # Removing extra as it can overflow some session stores
    redirect_to new_user_registration_url
  end
end

#google_authObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/generators/boring/oauth/google/install/templates/omniauth_callbacks_controller.rb', line 5

def google_auth
  # You need to implement the method below in your model (e.g. app/models/user.rb)
  @user = User.from_omniauth(request.env["omniauth.auth"])

  if @user.persisted?
     @user, event: :authentication #this will throw if @user is not activated
    set_flash_message(:notice, :success, kind: "Google") if is_navigational_format?
  else
    session["devise.google_data"] = request.env["omniauth.auth"].except(:extra) # Removing extra as it can overflow some session stores
    redirect_to new_user_registration_url
  end
end

#twitterObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/generators/boring/oauth/twitter/install/templates/omniauth_callbacks_controller.rb', line 5

def twitter
  # You need to implement the method below in your model (e.g. app/models/user.rb)
  @user = User.from_omniauth(request.env["omniauth.auth"])

  if @user.persisted?
     @user, event: :authentication #this will throw if @user is not activated
    set_flash_message(:notice, :success, kind: "Twitter") if is_navigational_format?
  else
    session["devise.twitter_data"] = request.env["omniauth.auth"].except(:extra) # Removing extra as it can overflow some session stores
    redirect_to new_user_registration_url
  end
end