[rabbitmq-discuss] plugin code help

Prabodh Upreti prabodh.upreti at vce.com
Fri Nov 16 20:22:23 GMT 2012


I have this simple method

http_callcas(Username) ->
    {ok, CasPath} = application:get_env(rabbitmq_cas_authen, user_path),  
    {ok, ServiceUrl} = application:get_env(rabbitmq_cas_authen,
service_url),
    Body = "service=" ++ ServiceUrl ++ "&" ++ "ticket=" ++ Username, 
	case httpc:request(post, {CasPath,[], "application/x-www-form-urlencoded",
Body}, [{ssl, [{verify, 0}]}], []) of
			{ok, {{_HTTP, Code, _}, _Headers, Body}} ->
            case Code of
                200 -> case string:str(Body, "yes~n~nadmin") of
                           {error, _} = E -> E;
                           0 -> true;
                           _ -> false                            
                          end;                           
                _   -> {error, {Code, Body}}
            end;
        {error, _} = E ->
            E       
	 end.

The external server returns

true
admin  (the logged in user)

If I get this response back then I want to let the user login to the system. 
I am an Erlang newbie. Is there a problem with this code. thank you.





--
View this message in context: http://rabbitmq.1065348.n5.nabble.com/plugin-code-help-tp23469.html
Sent from the RabbitMQ mailing list archive at Nabble.com.


More information about the rabbitmq-discuss mailing list