module Facebook::Auth::Devise
Public Instance Methods
create()
click to toggle source
based on OmniAuth 2 railscast
# File lib/facebook/auth/devise.rb, line 13 def create authenticated? ? authenticated : try_authenticate_user end
destroy()
click to toggle source
# File lib/facebook/auth/devise.rb, line 17 def destroy current_user_authentication.destroy user_authentication_destroyed end
index()
click to toggle source
# File lib/facebook/auth/devise.rb, line 8 def index @authentications = current_user.authentications if current_user end
Protected Instance Methods
after_authenticate_new_user(user)
click to toggle source
# File lib/facebook/auth/devise.rb, line 56 def after_authenticate_new_user user end
authenticate_new_user()
click to toggle source
# File lib/facebook/auth/devise.rb, line 49 def authenticate_new_user fb_login! user = new_user.authentications.build(:provider => auth_provider, :uid => fb_my_id) user.save ? authenticated_user_saved : authenticated_user_not_saved after_authenticate_new_user(user) end
authenticate_user()
click to toggle source
# File lib/facebook/auth/devise.rb, line 42 def authenticate_user # fb_login! current_user.authentications.create(:provider => auth_provider, :uid => fb_my_id) flash[:notice] = t "#{auth_provider}.auth.success" redirect_to authentications_url end
authenticated()
click to toggle source
# File lib/facebook/auth/devise.rb, line 33 def authenticated flash[:notice] = t "#{auth_provider}.auth.signed_in" sign_in_and_redirect(:user, authentication.user) end
authenticated?()
click to toggle source
# File lib/facebook/auth/devise.rb, line 68 def authenticated? auth_sessions? && authentication end
authenticated_user_not_saved()
click to toggle source
# File lib/facebook/auth/devise.rb, line 64 def authenticated_user_not_saved redirect_to new_user_registration_url end
authenticated_user_saved()
click to toggle source
# File lib/facebook/auth/devise.rb, line 59 def authenticated_user_saved flash[:notice] = t "#{auth_provider}.auth.signed_in" sign_in_and_redirect(:user, user) end
authentication()
click to toggle source
# File lib/facebook/auth/devise.rb, line 72 def authentication @authentication ||= Authentication.find_by_provider_and_uid(auth_provider, fb_my_id) end
current_user_authentication()
click to toggle source
# File lib/facebook/auth/devise.rb, line 29 def current_user_authentication @authentication ||= current_user.authentications.find(params[:id]) end
new_user()
click to toggle source
override as needed
# File lib/facebook/auth/devise.rb, line 77 def new_user User.new end
try_authenticate_user()
click to toggle source
# File lib/facebook/auth/devise.rb, line 38 def try_authenticate_user current_user ? authenticate_user : authenticate_new_user end
user_authentication_destroyed()
click to toggle source
# File lib/facebook/auth/devise.rb, line 24 def user_authentication_destroyed flash[:notice] = t "#{auth_provider}.auth.destroyed" redirect_to authentications_url end