I have the following in my Omniauth callback:
@user = User.find_for_linked_in_oauth(env["omniauth.auth"], current_user)
I expect either way to get a user object. Her is the User method. Right now, I am testing the case where it cannot find an existing User because it hasn’t been created yet:
def self.find_for_linked_in_oauth(omniauth_hash, signed_in_resource=nil)
debugger
#omniauth_hash is a hash passed in from env["omniauth_hash"] by callback controller
linkedin_uid = omniauth_hash['uid']
debugger
if user = User.find_by_linkedin_uid(linkedin_uid)
debugger
user
else # Create an user with a stub password.
#redirect to a page to ask for an email address and display information
#User.create!(:email => "token@email.com", :linkedin_uid => linkedin_uid, :password => Devise.friendly_token[0,20])
user = User.new
user.first_name = omniauth_hash['user_info']['first_name']
user.last_name = omniauth_hash['user_info']['last_name']
user.linkedin_uid = linkedin_uid
user
debugger
end
Currently, with debugger, I get back ‘1’ as the value for p @user.
I want the newly created user object to be passed back so I can then ask the current user to add additional information before saving it.
Why am I not getting the newly created user as the value of @user?
try to change places
useranddebuggerso it will returnuser