couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject chttpd commit: updated refs/heads/fix-users-doc-in-conflict to 562e2b6
Date Sat, 23 Apr 2016 23:28:46 GMT
Repository: couchdb-chttpd
Updated Branches:
  refs/heads/fix-users-doc-in-conflict [created] 562e2b670


restore 1.x behaviour: user docs in conflict cannot login


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/562e2b67
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/562e2b67
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/562e2b67

Branch: refs/heads/fix-users-doc-in-conflict
Commit: 562e2b67065f47523f205b5b33af1be9dcd3592a
Parents: 1ca8642
Author: Jan Lehnardt <jan@apache.org>
Authored: Sun Apr 24 01:28:32 2016 +0200
Committer: Jan Lehnardt <jan@apache.org>
Committed: Sun Apr 24 01:28:32 2016 +0200

----------------------------------------------------------------------
 src/chttpd_auth_cache.erl | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/562e2b67/src/chttpd_auth_cache.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_auth_cache.erl b/src/chttpd_auth_cache.erl
index 8a64ae7..ef75da3 100644
--- a/src/chttpd_auth_cache.erl
+++ b/src/chttpd_auth_cache.erl
@@ -48,10 +48,7 @@ get_user_creds(_Req, UserName) when is_binary(UserName) ->
 	        couch_util:get_value(<<"roles">>, UserProps))
         end
     end,
-    case Resp of
-        nil -> nil;
-        _ -> {ok, Resp, nil}
-    end.
+    validate_user_creds(Resp).
 
 update_user_creds(_Req, UserDoc, _Ctx) ->
     {_, Ref} = spawn_monitor(fun() ->
@@ -163,7 +160,7 @@ changes_callback({error, _}, EndSeq) ->
     exit({seq, EndSeq}).
 
 load_user_from_db(UserName) ->
-    try fabric:open_doc(dbname(), docid(UserName), [?ADMIN_CTX, ejson_body]) of
+    try fabric:open_doc(dbname(), docid(UserName), [?ADMIN_CTX, ejson_body, conflicts]) of
 	{ok, Doc} ->
 	    {Props} = couch_doc:to_json_obj(Doc, []),
 	    Props;
@@ -209,3 +206,18 @@ update_doc_ignoring_conflict(DbName, Doc, Options) ->
         throw:conflict ->
             ok
     end.
+
+validate_user_creds(nil) ->
+    nil;
+validate_user_creds(UserCreds) ->
+    couch_log:info("~n~n validate_user_creds: ~p~n~n", [UserCreds]),
+    case couch_util:get_value(<<"_conflicts">>, UserCreds) of
+    undefined ->
+        ok;
+    _ConflictList ->
+        throw({unauthorized,
+            <<"User document conflicts must be resolved before the document",
+              " is used for authentication purposes.">>
+        })
+    end,
+    {ok, UserCreds, nil}.


Mime
View raw message