class Users::OmniauthCallbacksController

Public Instance Methods

facebook() click to toggle source
# 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?
    sign_in_and_redirect @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
failure() click to toggle source
# File lib/generators/boring/oauth/facebook/install/templates/omniauth_callbacks_controller.rb, line 18
def failure
  redirect_to root_path
end
github() click to toggle source
# 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?
    sign_in_and_redirect @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_auth() click to toggle source
# 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?
    sign_in_and_redirect @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
twitter() click to toggle source
# 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?
    sign_in_and_redirect @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