Hi all,
I’ve got a Rails app with a ApplicationController that looks like this:
class ApplicationController < ActionController::Base
before_filter :authorize, :except => :login
def authorize
unless session[:user]
flash[:notice] = "Please log in"
session[:jumpto] = request.parameters
redirect_to :controller => "login", :action => "login"
end
end
end
So, basically, redirect a user to the login screen if they haven’t
already
logged in. Pretty standard stuff.
But, if I want to setup a web service, how do I set session data from
the
client side through, say, an xmlrpc call using layered dispatching?
I’ve tried
messing around with the block form of the web_service, and even tried
setting
up a LoginApi and LoginService, but no luck.
I’d like to be able to do this:
require ‘xmlprc/client’
rpc = XMLRPC::Client.new(‘localhost’, ‘http://localhost/webservice/api’,
3000)
rpc.call(‘login.login’, user, password) # Set session data here
rpc.call(‘foo.findFooById’, 2) # Go on my merry way
I googled around a bit and couldn’t quite find the answer I was looking
for.
That, or I’m just not “getting it”.
What’s the best/proper way to handle this?
Thanks,
Dan