couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r915476 - in /couchdb/trunk: THANKS src/couchdb/couch_httpd_auth.erl
Date Tue, 23 Feb 2010 18:48:34 GMT
Author: davisp
Date: Tue Feb 23 18:48:33 2010
New Revision: 915476

URL: http://svn.apache.org/viewvc?rev=915476&view=rev
Log:
Minor cleanup thanks to Joel Clark.

Closes COUCHDB-669


Modified:
    couchdb/trunk/THANKS
    couchdb/trunk/src/couchdb/couch_httpd_auth.erl

Modified: couchdb/trunk/THANKS
URL: http://svn.apache.org/viewvc/couchdb/trunk/THANKS?rev=915476&r1=915475&r2=915476&view=diff
==============================================================================
--- couchdb/trunk/THANKS (original)
+++ couchdb/trunk/THANKS Tue Feb 23 18:48:33 2010
@@ -47,5 +47,6 @@
  * Jan Kassens <jan@kassens.net>
  * James Marca <jmarca@translab.its.uci.edu>
  * Matt Goodall <matt.goodall@gmail.com>
+ * Joel Clark <unsigned_char@yahoo.com>
 
 For a list of authors see the `AUTHORS` file.

Modified: couchdb/trunk/src/couchdb/couch_httpd_auth.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_auth.erl?rev=915476&r1=915475&r2=915476&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_auth.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_auth.erl Tue Feb 23 18:48:33 2010
@@ -312,8 +312,7 @@
                 throw({bad_request, Reason})
         end,
         % Verify expiry and hash
-        {NowMS, NowS, _} = erlang:now(),
-        CurrentTime = NowMS * 1000000 + NowS,
+        CurrentTime = make_cookie_time(),
         case couch_config:get("couch_httpd_auth", "secret", nil) of
         nil -> 
             ?LOG_ERROR("cookie auth secret is not set",[]),
@@ -362,8 +361,7 @@
     Cookies = mochiweb_cookies:parse_cookie(CookieHeader),
     AuthSession = proplists:get_value("AuthSession", Cookies),
     if AuthSession == undefined ->
-        {NowMS, NowS, _} = erlang:now(),
-        TimeStamp = NowMS * 1000000 + NowS,
+        TimeStamp = make_cookie_time(),
         [cookie_auth_cookie(?b2l(User), Secret, TimeStamp)];
     true ->
         []
@@ -414,8 +412,7 @@
         true ->
             % setup the session cookie
             Secret = ?l2b(ensure_cookie_auth_secret()),
-            {NowMS, NowS, _} = erlang:now(),
-            CurrentTime = NowMS * 1000000 + NowS,
+            CurrentTime = make_cookie_time(),
             Cookie = cookie_auth_cookie(?b2l(UserName), <<Secret/binary, UserSalt/binary>>,
CurrentTime),
             % TODO document the "next" feature in Futon
             {Code, Headers} = case couch_httpd:qs_value(Req, "next", nil) of
@@ -487,3 +484,7 @@
     list_to_integer(Value);
 to_int(Value) when is_integer(Value) ->
     Value.
+
+make_cookie_time() ->
+    {NowMS, NowS, _} = erlang:now(),
+    NowMS * 1000000 + NowS.



Mime
View raw message