Skip to content

Instantly share code, notes, and snippets.

@johngibb
Created March 5, 2011 00:56
Show Gist options
  • Save johngibb/855992 to your computer and use it in GitHub Desktop.
Save johngibb/855992 to your computer and use it in GitHub Desktop.
Faceback Omniauth Callback
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
# You need to implement the method below in your model
@user = User.find_for_facebook_oauth(env["omniauth.auth"], current_user)
if @user.persisted?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook"
sign_in_and_redirect @user, :event => :authentication
else
session["devise.facebook_data"] = env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment