Skip to content

Instantly share code, notes, and snippets.

@johndel
Created July 20, 2013 18:33
Show Gist options
  • Save johndel/6046007 to your computer and use it in GitHub Desktop.
Save johndel/6046007 to your computer and use it in GitHub Desktop.
omniauth_controller for multiple providers.
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def all
#raise request.env["omniauth.auth"].to_yaml
omniauth = request.env["omniauth.auth"]
provider = User.from_omniauth(omniauth)
if provider.persisted?
flash.notice = "Successful login"
sign_in(provider.user)
@after_sign_in_url = after_sign_in_path_for(provider.user)
else # If user has a validation error
session["devise.user_attributes"] = user.attributes
redirect_to new_user_registration_url
end
end
alias_method :facebook, :all
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment