I'm writing a rails3 app using authlogic and authlogic-oid to allow the user to login and register using their LinkedIn account. I'm able to call out to LinkedIn to authenticate but the issue I'm having is that when the call returns to my rails app, it is calling a GET on /user_sessions and invoking the index controller instead of executing the remainder of the create controller. Here's the controller:
# POST /user_sessions
def create
@user_session = UserSession.new(params[:user_session])
@user_session.save do |result| # <-- redirects to api.linkedin.com here
if result
flash[:success] = "Login successful!"
redirect_back_or @user_session.user_path
else
flash.now[:error] = "Invalid username/password combination."
@title = "Sign in"
render 'new'
end
end
end
Everything works great until if result
which never gets called because the program resumes execution in the index
controller instead of picking up where it left off. Any ideas on how to fix this would be greatly appreciated.
Edit: it seems my assumption that the controller was not completing execution was wrong. I've put in a bunch of debug statements and learned that the the program does resume execution in this controller after @user_session.save but it is not executing either condition on the if statement. I'm very confused on this one.