diff options
author | Adam Kocoloski <kocolosk@apache.org> | 2009-09-24 03:37:59 +0000 |
---|---|---|
committer | Adam Kocoloski <kocolosk@apache.org> | 2009-09-24 03:37:59 +0000 |
commit | fb9cf1e5dc3381d499bbeae4f9266bbd612d1ddb (patch) | |
tree | e16c66e597564d29a00e827e99d2cf57d0f3faa7 | |
parent | d9e9b141f7fab5f18c6e37e0c545f74775514e40 (diff) |
update the AuthSession cookie even if no Set-Cookie is already present
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@818357 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/couchdb/couch_httpd_auth.erl | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/couchdb/couch_httpd_auth.erl b/src/couchdb/couch_httpd_auth.erl index 544f0f80..5c7e565d 100644 --- a/src/couchdb/couch_httpd_auth.erl +++ b/src/couchdb/couch_httpd_auth.erl @@ -259,17 +259,15 @@ cookie_auth_header(#httpd{user_ctx=#user_ctx{name=User}, auth={Secret, true}}, H % or logout handler. % The login and logout handlers need to set the AuthSession cookie % themselves. - case proplists:get_value("Set-Cookie", Headers) of - undefined -> []; - Cookie -> - case proplists:get_value("AuthSession", - mochiweb_cookies:parse_cookie(Cookie), undefined) of - undefined -> - {NowMS, NowS, _} = erlang:now(), - TimeStamp = NowMS * 1000000 + NowS, - [cookie_auth_cookie(?b2l(User), Secret, TimeStamp)]; - _Else -> [] - end + CookieHeader = proplists:get_value("Set-Cookie", Headers, ""), + Cookies = mochiweb_cookies:parse_cookie(CookieHeader), + AuthSession = proplists:get_value("AuthSession", Cookies), + if AuthSession == undefined -> + {NowMS, NowS, _} = erlang:now(), + TimeStamp = NowMS * 1000000 + NowS, + [cookie_auth_cookie(?b2l(User), Secret, TimeStamp)]; + true -> + [] end; cookie_auth_header(_Req, _Headers) -> []. |