This is an automated email from the ASF dual-hosted git repository. rnewson pushed a commit to branch upgrade_if_user_doc in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 41274c7faf85d65f8b49dd4a6cf9d6bc5371ffa5 Author: Robert Newson <rnew...@apache.org> AuthorDate: Thu Sep 12 19:51:11 2024 +0100 only upgrade password hashes if there is a user doc --- src/couch/src/couch_password_hasher.erl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/couch/src/couch_password_hasher.erl b/src/couch/src/couch_password_hasher.erl index d947500d6..1990a326e 100644 --- a/src/couch/src/couch_password_hasher.erl +++ b/src/couch/src/couch_password_hasher.erl @@ -40,11 +40,11 @@ maybe_upgrade_password_hash(AuthModule, UserName, Password, UserProps) -> UpgradeEnabled = config:get_boolean("chttpd_auth", "upgrade_hash_on_auth", true), - IsAdmin = is_admin(UserProps), + IsDoc = is_doc(UserProps), NeedsUpgrade = needs_upgrade(UserProps), InProgress = in_progress(AuthModule, UserName), if - UpgradeEnabled andalso not IsAdmin andalso NeedsUpgrade andalso not InProgress -> + UpgradeEnabled andalso IsDoc andalso NeedsUpgrade andalso not InProgress -> gen_server:cast( ?MODULE, {upgrade_password_hash, AuthModule, UserName, Password, UserProps} ); @@ -106,9 +106,8 @@ hash_admin_passwords_int(Persist) -> couch_passwords:get_unhashed_admins() ). -is_admin(UserProps) -> - Roles = couch_util:get_value(<<"roles">>, UserProps, []), - lists:member(<<"_admin">>, Roles). +is_doc(UserProps) -> + couch_util:get_value(<<"_rev">>, UserProps) /= undefined. needs_upgrade(UserProps) -> CurrentScheme = couch_util:get_value(<<"password_scheme">>, UserProps),