From fb9cf1e5dc3381d499bbeae4f9266bbd612d1ddb Mon Sep 17 00:00:00 2001 From: Adam Kocoloski Date: Thu, 24 Sep 2009 03:37:59 +0000 Subject: 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 --- src/couchdb/couch_httpd_auth.erl | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src') 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) -> []. -- cgit v1.2.3