I am using Omniauth gem to provide Facebook authentication in my app, but the url, with which Facebook redirects user is http://localhost:3000/users/login#_=_
, this happens right after the user enters its email/password. I don't know whats causing it, Google seems to be working fine.
Omniauth Callback
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def all
user = User.from_omniauth(request.env["omniauth.auth"])
if user.persisted?
flash.notice = "Signed in!"
sign_in_and_redirect user
else
session["devise.user_attributes"] = user.attributes
redirect_to new_user_registration_url
end
end
# alias_method :twitter, :all
alias_method :facebook, :all
alias_method :google_oauth2, :all
end
Routes.rb
devise_for :users, path_names: {sign_in: "login", sign_out: "logout"},
controllers: {omniauth_callbacks: "omniauth_callbacks"}
User.rb
def self.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_create do |user|
user.name = auth.info.name
user.provider = auth.provider
user.uid = auth.uid
user.email = auth.info.email
end
end
def self.new_with_session(params, session)
if session["devise.user_attributes"]
new(session["devise.user_attributes"]) do |user|
user.attributes = params
user.valid?
end
else
super
end
end