fix: allow custom password field when using disableLocalStrategy: true (#11893)

Fixes https://github.com/payloadcms/payload/issues/11888

Previously, if you had `disableLocalStategy: true` and a custom
`password` field, Payload would still control it in `update.ts` by
deleting. Now, we don't do that in this case, unless we have
`disableLocalStetegy.enableFields: true`.
This commit is contained in:
Sasha
2025-04-04 20:52:10 +03:00
committed by GitHub
parent b76844dac9
commit 8ad22eb1c0
4 changed files with 89 additions and 1 deletions

View File

@@ -99,7 +99,14 @@ export const updateDocument = async <
const password = data?.password
const shouldSaveDraft =
Boolean(draftArg && collectionConfig.versions.drafts) && data._status !== 'published'
const shouldSavePassword = Boolean(password && collectionConfig.auth && !shouldSaveDraft)
const shouldSavePassword = Boolean(
password &&
collectionConfig.auth &&
(!collectionConfig.auth.disableLocalStrategy ||
(typeof collectionConfig.auth.disableLocalStrategy === 'object' &&
collectionConfig.auth.disableLocalStrategy.enableFields)) &&
!shouldSaveDraft,
)
// /////////////////////////////////////
// Handle potentially locked documents