Reputation: 167
Currently I am using Rails 4.0.8 to implement my rails app. Now I want to upgrade to rails 4.2, in this app of mine I am using Devise and OmniAuth for authentication and it is working fine for rails 4.0.8. Now when I try to upgrade to rails 4.2.3 all of a sudden my authentication system stopped working. It is giving the following errors
ArgumentError at /users/auth/facebook/callback
wrong number of arguments (2 for 1) and it is pointing to the line in controller sign_in_and_redirect(user)
The code for my OmniAuth callback controller is :
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
skip_before_filter :authenticate_user!
def all
p env["omniauth.auth"]
user = User.from_omniauth(env["omniauth.auth"], current_user)
if user.persisted?
flash[:notice] = "You are in..!!! Go to edit profile to see the status for the accounts"
sign_in_and_redirect(user)
else
session["devise.user_attributes"] = user.attributes
redirect_to new_user_registration_url
end
end
def failure
#handle you logic here..
#and delegate to super.
super
end
alias_method :facebook, :all
alias_method :google_oauth2, :all
end
Upvotes: 0
Views: 97
Reputation: 44370
Problem in an sign_in_and_redirect() method, it is allows two arguments resource
and event
, fix your code to:
def all
p env["omniauth.auth"]
user = User.from_omniauth(env["omniauth.auth"], current_user)
if user.persisted?
flash[:notice] = "You are in..!!! Go to edit profile to see the status for the accounts"
sign_in_and_redirect(user, event: :authentication)
else
session["devise.user_attributes"] = user.attributes
redirect_to new_user_registration_url
end
end
Upvotes: 1