From aea47cc3831fd7b5a8c926557ad79cffbe9639ef Mon Sep 17 00:00:00 2001 From: Filipe David Borba Manana Date: Wed, 4 Aug 2010 10:36:35 +0000 Subject: Allow POSTing of a JSON object to /_session/ for login. Closes COUCHDB-842, patch by Jonathan D. Knezek. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@982200 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_httpd_auth.erl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/couchdb') diff --git a/src/couchdb/couch_httpd_auth.erl b/src/couchdb/couch_httpd_auth.erl index 7023e7f3..f76898e1 100644 --- a/src/couchdb/couch_httpd_auth.erl +++ b/src/couchdb/couch_httpd_auth.erl @@ -247,13 +247,17 @@ ensure_cookie_auth_secret() -> % session handlers % Login handler with user db -% TODO this should also allow a JSON POST handle_session_req(#httpd{method='POST', mochi_req=MochiReq}=Req) -> ReqBody = MochiReq:recv_body(), Form = case MochiReq:get_primary_header_value("content-type") of % content type should be json "application/x-www-form-urlencoded" ++ _ -> mochiweb_util:parse_qs(ReqBody); + "application/json" ++ _ -> + {Pairs} = ?JSON_DECODE(ReqBody), + lists:map(fun({Key, Value}) -> + {?b2l(Key), ?b2l(Value)} + end, Pairs); _ -> [] end, -- cgit v1.2.3