Created
July 20, 2013 18:33
-
-
Save johndel/6046007 to your computer and use it in GitHub Desktop.
omniauth_controller for multiple providers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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