-
-
Save indutny/9bd93eb6e091943dae7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/couchdb/couch_server.erl b/src/couchdb/couch_server.erl | |
index 440af62..13734b3 100644 | |
--- a/src/couchdb/couch_server.erl | |
+++ b/src/couchdb/couch_server.erl | |
@@ -93,7 +93,51 @@ maybe_add_sys_db_callbacks(DbName, Options) -> | |
sys_db | Options | |
]; | |
_ -> | |
- Options | |
+ case DbName of | |
+ "public_users" -> | |
+ F = fun(#doc{id = <<?DESIGN_DOC_PREFIX, _/binary>>} = Doc, _) -> | |
+ Doc; | |
+ (#doc{body = {Body}} = Doc, #db{user_ctx = UserCtx} = Db) -> | |
+ #user_ctx{name=Name} = UserCtx, | |
+ DocName = couch_util:get_value(<<"name">>, Body), | |
+ case (catch couch_db:check_is_admin(Db)) of | |
+ ok -> | |
+ Doc; | |
+ _ when Name =:= DocName -> | |
+ Doc; | |
+ _ -> | |
+ #doc{ | |
+ id = Id, | |
+ revs = RevisionPath, | |
+ atts = Atts, | |
+ deleted = Deleted | |
+ } = Doc, | |
+ #doc{ | |
+ id = Id, | |
+ revs = RevisionPath, | |
+ atts = Atts, | |
+ deleted = Deleted, | |
+ body = {lists:filter(fun({Key, _}) -> | |
+ (Key =/= <<"salt">>) and | |
+ (Key =/= <<"password">>) and | |
+ (Key =/= <<"password_sha">>) and | |
+ (Key =/= <<"password_scheme">>) and | |
+ (Key =/= <<"derived_Key">>) and | |
+ (Key =/= <<"pbkdf2">>) and | |
+ (Key =/= <<"iterations">>) and | |
+ (Key =/= <<"bcrypt">>) and | |
+ (Key =/= <<"x-csrf-token">>) | |
+ end, Body)} | |
+ } | |
+ end | |
+ end, | |
+ [ | |
+ {after_doc_read, F}, | |
+ Options | |
+ ]; | |
+ _Else -> | |
+ Options | |
+ end | |
end | |
end. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment