payload 3.47.0-internal.b17506e → 3.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/endpoints/me.d.ts.map +1 -1
- package/dist/auth/endpoints/me.js +16 -1
- package/dist/auth/endpoints/me.js.map +1 -1
- package/dist/auth/operations/login.d.ts.map +1 -1
- package/dist/auth/operations/login.js +2 -0
- package/dist/auth/operations/login.js.map +1 -1
- package/dist/auth/operations/me.d.ts +6 -1
- package/dist/auth/operations/me.d.ts.map +1 -1
- package/dist/auth/operations/me.js +6 -2
- package/dist/auth/operations/me.js.map +1 -1
- package/dist/auth/strategies/local/resetLoginAttempts.d.ts.map +1 -1
- package/dist/auth/strategies/local/resetLoginAttempts.js +1 -1
- package/dist/auth/strategies/local/resetLoginAttempts.js.map +1 -1
- package/dist/exports/shared.d.ts +1 -0
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +1 -0
- package/dist/exports/shared.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js +5 -3
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/uploads/checkFileRestrictions.d.ts +1 -1
- package/dist/uploads/checkFileRestrictions.d.ts.map +1 -1
- package/dist/uploads/checkFileRestrictions.js +34 -13
- package/dist/uploads/checkFileRestrictions.js.map +1 -1
- package/dist/uploads/endpoints/getFile.d.ts.map +1 -1
- package/dist/uploads/endpoints/getFile.js +3 -1
- package/dist/uploads/endpoints/getFile.js.map +1 -1
- package/dist/uploads/generateFileData.js +1 -1
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/types.d.ts +2 -1
- package/dist/uploads/types.d.ts.map +1 -1
- package/dist/uploads/types.js.map +1 -1
- package/dist/utilities/sanitizeUserDataForEmail.d.ts +16 -0
- package/dist/utilities/sanitizeUserDataForEmail.d.ts.map +1 -0
- package/dist/utilities/sanitizeUserDataForEmail.js +57 -0
- package/dist/utilities/sanitizeUserDataForEmail.js.map +1 -0
- package/dist/utilities/sanitizeUserDataForEmail.spec.js +133 -0
- package/dist/utilities/sanitizeUserDataForEmail.spec.js.map +1 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/me.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/me.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAY3D,eAAO,MAAM,SAAS,EAAE,cAoDvB,CAAA"}
|
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
import { status as httpStatus } from 'http-status';
|
|
2
2
|
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
|
|
3
3
|
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
4
|
+
import { isNumber } from '../../utilities/isNumber.js';
|
|
5
|
+
import { sanitizeJoinParams } from '../../utilities/sanitizeJoinParams.js';
|
|
6
|
+
import { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js';
|
|
7
|
+
import { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js';
|
|
4
8
|
import { extractJWT } from '../extractJWT.js';
|
|
5
9
|
import { meOperation } from '../operations/me.js';
|
|
6
10
|
export const meHandler = async (req)=>{
|
|
11
|
+
const { searchParams } = req;
|
|
7
12
|
const collection = getRequestCollection(req);
|
|
8
13
|
const currentToken = extractJWT(req);
|
|
14
|
+
const depthFromSearchParams = searchParams.get('depth');
|
|
15
|
+
const draftFromSearchParams = searchParams.get('depth');
|
|
16
|
+
const { depth: depthFromQuery, draft: draftFromQuery, joins, populate, select } = req.query;
|
|
17
|
+
const depth = depthFromQuery || depthFromSearchParams;
|
|
18
|
+
const draft = draftFromQuery || draftFromSearchParams;
|
|
9
19
|
const result = await meOperation({
|
|
10
20
|
collection,
|
|
11
21
|
currentToken: currentToken,
|
|
12
|
-
|
|
22
|
+
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
23
|
+
draft: draft === 'true',
|
|
24
|
+
joins: sanitizeJoinParams(joins),
|
|
25
|
+
populate: sanitizePopulateParam(populate),
|
|
26
|
+
req,
|
|
27
|
+
select: sanitizeSelectParam(select)
|
|
13
28
|
});
|
|
14
29
|
if (collection.config.auth.removeTokenFromResponses) {
|
|
15
30
|
delete result.token;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/auth/endpoints/me.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { extractJWT } from '../extractJWT.js'\nimport { meOperation } from '../operations/me.js'\n\nexport const meHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const currentToken = extractJWT(req)\n\n const result = await meOperation({\n collection,\n currentToken: currentToken!,\n req,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n ...result,\n message: req.t('authentication:account'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["status","httpStatus","getRequestCollection","headersWithCors","extractJWT","meOperation","meHandler","req","collection","currentToken","result","config","auth","removeTokenFromResponses","token","Response","json","message","t","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/endpoints/me.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\nimport type { JoinParams } from '../../utilities/sanitizeJoinParams.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizeJoinParams } from '../../utilities/sanitizeJoinParams.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { extractJWT } from '../extractJWT.js'\nimport { meOperation } from '../operations/me.js'\n\nexport const meHandler: PayloadHandler = async (req) => {\n const { searchParams } = req\n const collection = getRequestCollection(req)\n const currentToken = extractJWT(req)\n const depthFromSearchParams = searchParams.get('depth')\n const draftFromSearchParams = searchParams.get('depth')\n\n const {\n depth: depthFromQuery,\n draft: draftFromQuery,\n joins,\n populate,\n select,\n } = req.query as {\n depth?: string\n draft?: string\n joins?: JoinParams\n populate?: Record<string, unknown>\n select?: Record<string, unknown>\n }\n\n const depth = depthFromQuery || depthFromSearchParams\n const draft = draftFromQuery || draftFromSearchParams\n\n const result = await meOperation({\n collection,\n currentToken: currentToken!,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: draft === 'true',\n joins: sanitizeJoinParams(joins),\n populate: sanitizePopulateParam(populate),\n req,\n select: sanitizeSelectParam(select),\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n ...result,\n message: req.t('authentication:account'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["status","httpStatus","getRequestCollection","headersWithCors","isNumber","sanitizeJoinParams","sanitizePopulateParam","sanitizeSelectParam","extractJWT","meOperation","meHandler","req","searchParams","collection","currentToken","depthFromSearchParams","get","draftFromSearchParams","depth","depthFromQuery","draft","draftFromQuery","joins","populate","select","query","result","Number","undefined","config","auth","removeTokenFromResponses","token","Response","json","message","t","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAKlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAAS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AAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAS,MAAM,sBAAsB,CAAA;AAsBjE,MAAM,MAAM,MAAM,GAAG;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,SAAS,CAAC,KAAK,SAAS,cAAc,IAAI;IACpD,UAAU,EAAE,UAAU,CAAA;IACtB,IAAI,EAAE,gCAAgC,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAA;IACtD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,KAAK,wBAAwB,GAAG;IAC9B,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,EAAE,GAAG,CAAA;CACV,CAAA;AAED,eAAO,MAAM,oBAAoB,0CAI9B,wBAAwB,SAQ1B,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,KAAK,SAAS,cAAc,gBACjD,SAAS,CAAC,KAAK,CAAC,KAC7B,OAAO,CAAC;IAAE,IAAI,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAA;CAAE,GAAG,MAAM,CA+T1D,CAAA"}
|
|
@@ -207,6 +207,8 @@ export const loginOperation = async (incomingArgs)=>{
|
|
|
207
207
|
req,
|
|
208
208
|
returning: false
|
|
209
209
|
});
|
|
210
|
+
user.collection = collectionConfig.slug;
|
|
211
|
+
user._strategy = 'local-jwt';
|
|
210
212
|
fieldsToSignArgs.sid = newSessionID;
|
|
211
213
|
}
|
|
212
214
|
const fieldsToSign = getFieldsToSign(fieldsToSignArgs);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/auth/operations/login.ts"],"sourcesContent":["import { v4 as uuid } from 'uuid'\n\nimport type {\n AuthOperationsFromCollectionSlug,\n Collection,\n DataFromCollectionSlug,\n} from '../../collections/config/types.js'\nimport type { CollectionSlug, TypedUser } from '../../index.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\n\nimport { buildAfterOperation } from '../../collections/operations/utils.js'\nimport {\n AuthenticationError,\n LockedAuth,\n UnverifiedEmail,\n ValidationError,\n} from '../../errors/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { Forbidden } from '../../index.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { sanitizeInternalFields } from '../../utilities/sanitizeInternalFields.js'\nimport { getFieldsToSign } from '../getFieldsToSign.js'\nimport { getLoginOptions } from '../getLoginOptions.js'\nimport { isUserLocked } from '../isUserLocked.js'\nimport { jwtSign } from '../jwt.js'\nimport { removeExpiredSessions } from '../removeExpiredSessions.js'\nimport { authenticateLocalStrategy } from '../strategies/local/authenticate.js'\nimport { incrementLoginAttempts } from '../strategies/local/incrementLoginAttempts.js'\nimport { resetLoginAttempts } from '../strategies/local/resetLoginAttempts.js'\n\nexport type Result = {\n exp?: number\n token?: string\n user?: TypedUser\n}\n\nexport type Arguments<TSlug extends CollectionSlug> = {\n collection: Collection\n data: AuthOperationsFromCollectionSlug<TSlug>['login']\n depth?: number\n overrideAccess?: boolean\n req: PayloadRequest\n showHiddenFields?: boolean\n}\n\ntype CheckLoginPermissionArgs = {\n loggingInWithUsername?: boolean\n req: PayloadRequest\n user: any\n}\n\nexport const checkLoginPermission = ({\n loggingInWithUsername,\n req,\n user,\n}: CheckLoginPermissionArgs) => {\n if (!user) {\n throw new AuthenticationError(req.t, Boolean(loggingInWithUsername))\n }\n\n if (isUserLocked(new Date(user.lockUntil).getTime())) {\n throw new LockedAuth(req.t)\n }\n}\n\nexport const loginOperation = async <TSlug extends CollectionSlug>(\n incomingArgs: Arguments<TSlug>,\n): Promise<{ user: DataFromCollectionSlug<TSlug> } & Result> => {\n let args = incomingArgs\n\n if (args.collection.config.auth.disableLocalStrategy) {\n throw new Forbidden(args.req.t)\n }\n\n try {\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n if (args.collection.config.hooks?.beforeOperation?.length) {\n for (const hook of args.collection.config.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n collection: args.collection?.config,\n context: args.req.context,\n operation: 'login',\n req: args.req,\n })) || args\n }\n }\n\n const {\n collection: { config: collectionConfig },\n data,\n depth,\n overrideAccess,\n req,\n req: {\n fallbackLocale,\n locale,\n payload,\n payload: { secret },\n },\n showHiddenFields,\n } = args\n\n // /////////////////////////////////////\n // Login\n // /////////////////////////////////////\n\n const { email: unsanitizedEmail, password } = data\n const loginWithUsername = collectionConfig.auth.loginWithUsername\n\n const sanitizedEmail =\n typeof unsanitizedEmail === 'string' ? unsanitizedEmail.toLowerCase().trim() : null\n const sanitizedUsername =\n 'username' in data && typeof data?.username === 'string'\n ? data.username.toLowerCase().trim()\n : null\n\n const { canLoginWithEmail, canLoginWithUsername } = getLoginOptions(loginWithUsername)\n\n // cannot login with email, did not provide username\n if (!canLoginWithEmail && !sanitizedUsername) {\n throw new ValidationError({\n collection: collectionConfig.slug,\n errors: [{ message: req.i18n.t('validation:required'), path: 'username' }],\n })\n }\n\n // cannot login with username, did not provide email\n if (!canLoginWithUsername && !sanitizedEmail) {\n throw new ValidationError({\n collection: collectionConfig.slug,\n errors: [{ message: req.i18n.t('validation:required'), path: 'email' }],\n })\n }\n\n // can login with either email or username, did not provide either\n if (!sanitizedUsername && !sanitizedEmail) {\n throw new ValidationError({\n collection: collectionConfig.slug,\n errors: [\n { message: req.i18n.t('validation:required'), path: 'email' },\n { message: req.i18n.t('validation:required'), path: 'username' },\n ],\n })\n }\n\n // did not provide password for login\n if (typeof password !== 'string' || password.trim() === '') {\n throw new ValidationError({\n collection: collectionConfig.slug,\n errors: [{ message: req.i18n.t('validation:required'), path: 'password' }],\n })\n }\n\n let whereConstraint: Where = {}\n const emailConstraint: Where = {\n email: {\n equals: sanitizedEmail,\n },\n }\n const usernameConstraint: Where = {\n username: {\n equals: sanitizedUsername,\n },\n }\n\n if (canLoginWithEmail && canLoginWithUsername && (sanitizedUsername || sanitizedEmail)) {\n if (sanitizedUsername) {\n whereConstraint = {\n or: [\n usernameConstraint,\n {\n email: {\n equals: sanitizedUsername,\n },\n },\n ],\n }\n } else {\n whereConstraint = {\n or: [\n emailConstraint,\n {\n username: {\n equals: sanitizedEmail,\n },\n },\n ],\n }\n }\n } else if (canLoginWithEmail && sanitizedEmail) {\n whereConstraint = emailConstraint\n } else if (canLoginWithUsername && sanitizedUsername) {\n whereConstraint = usernameConstraint\n }\n\n let user = await payload.db.findOne<any>({\n collection: collectionConfig.slug,\n req,\n where: whereConstraint,\n })\n\n checkLoginPermission({\n loggingInWithUsername: Boolean(canLoginWithUsername && sanitizedUsername),\n req,\n user,\n })\n\n user.collection = collectionConfig.slug\n user._strategy = 'local-jwt'\n\n const authResult = await authenticateLocalStrategy({ doc: user, password })\n\n user = sanitizeInternalFields(user)\n\n const maxLoginAttemptsEnabled = args.collection.config.auth.maxLoginAttempts > 0\n\n if (!authResult) {\n if (maxLoginAttemptsEnabled) {\n await incrementLoginAttempts({\n collection: collectionConfig,\n doc: user,\n payload: req.payload,\n req,\n })\n }\n\n throw new AuthenticationError(req.t)\n }\n\n if (collectionConfig.auth.verify && user._verified === false) {\n throw new UnverifiedEmail({ t: req.t })\n }\n\n const fieldsToSignArgs: Parameters<typeof getFieldsToSign>[0] = {\n collectionConfig,\n email: sanitizedEmail!,\n user,\n }\n\n if (collectionConfig.auth.useSessions) {\n // Add session to user\n const newSessionID = uuid()\n const now = new Date()\n const tokenExpInMs = collectionConfig.auth.tokenExpiration * 1000\n const expiresAt = new Date(now.getTime() + tokenExpInMs)\n\n const session = { id: newSessionID, createdAt: now, expiresAt }\n\n if (!user.sessions?.length) {\n user.sessions = [session]\n } else {\n user.sessions = removeExpiredSessions(user.sessions)\n user.sessions.push(session)\n }\n\n await payload.db.updateOne({\n id: user.id,\n collection: collectionConfig.slug,\n data: user,\n req,\n returning: false,\n })\n\n fieldsToSignArgs.sid = newSessionID\n }\n\n const fieldsToSign = getFieldsToSign(fieldsToSignArgs)\n\n if (maxLoginAttemptsEnabled) {\n await resetLoginAttempts({\n collection: collectionConfig,\n doc: user,\n payload: req.payload,\n req,\n })\n }\n\n // /////////////////////////////////////\n // beforeLogin - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeLogin?.length) {\n for (const hook of collectionConfig.hooks.beforeLogin) {\n user =\n (await hook({\n collection: args.collection?.config,\n context: args.req.context,\n req: args.req,\n user,\n })) || user\n }\n }\n\n const { exp, token } = await jwtSign({\n fieldsToSign,\n secret,\n tokenExpiration: collectionConfig.auth.tokenExpiration,\n })\n\n req.user = user\n\n // /////////////////////////////////////\n // afterLogin - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterLogin?.length) {\n for (const hook of collectionConfig.hooks.afterLogin) {\n user =\n (await hook({\n collection: args.collection?.config,\n context: args.req.context,\n req: args.req,\n token,\n user,\n })) || user\n }\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n user = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth: depth!,\n doc: user,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n draft: undefined,\n fallbackLocale: fallbackLocale!,\n global: null,\n locale: locale!,\n overrideAccess: overrideAccess!,\n req,\n showHiddenFields: showHiddenFields!,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterRead?.length) {\n for (const hook of collectionConfig.hooks.afterRead) {\n user =\n (await hook({\n collection: args.collection?.config,\n context: req.context,\n doc: user,\n req,\n })) || user\n }\n }\n\n let result: { user: DataFromCollectionSlug<TSlug> } & Result = {\n exp,\n token,\n user,\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: args.collection?.config,\n operation: 'login',\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["v4","uuid","buildAfterOperation","AuthenticationError","LockedAuth","UnverifiedEmail","ValidationError","afterRead","Forbidden","killTransaction","sanitizeInternalFields","getFieldsToSign","getLoginOptions","isUserLocked","jwtSign","removeExpiredSessions","authenticateLocalStrategy","incrementLoginAttempts","resetLoginAttempts","checkLoginPermission","loggingInWithUsername","req","user","t","Boolean","Date","lockUntil","getTime","loginOperation","incomingArgs","args","collection","config","auth","disableLocalStrategy","hooks","beforeOperation","length","hook","context","operation","collectionConfig","data","depth","overrideAccess","fallbackLocale","locale","payload","secret","showHiddenFields","email","unsanitizedEmail","password","loginWithUsername","sanitizedEmail","toLowerCase","trim","sanitizedUsername","username","canLoginWithEmail","canLoginWithUsername","slug","errors","message","i18n","path","whereConstraint","emailConstraint","equals","usernameConstraint","or","db","findOne","where","_strategy","authResult","doc","maxLoginAttemptsEnabled","maxLoginAttempts","verify","_verified","fieldsToSignArgs","useSessions","newSessionID","now","tokenExpInMs","tokenExpiration","expiresAt","session","id","createdAt","sessions","push","updateOne","returning","sid","fieldsToSign","beforeLogin","exp","token","afterLogin","draft","undefined","global","result","error"],"mappings":"AAAA,SAASA,MAAMC,IAAI,QAAQ,OAAM;AAUjC,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SACEC,mBAAmB,EACnBC,UAAU,EACVC,eAAe,EACfC,eAAe,QACV,wBAAuB;AAC9B,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SAASC,eAAe,QAAQ,wBAAuB;AACvD,SAASC,eAAe,QAAQ,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BAAkBA;QACpB;QAEA,wCAAwC;QACxC,yBAAyB;QACzB,wCAAwC;QAExC,IAAIR,iBAAiBN,KAAK,EAAE5B,WAAW8B,QAAQ;YAC7C,KAAK,MAAMC,QAAQG,iBAAiBN,KAAK,CAAC5B,SAAS,CAAE;gBACnDe,OACE,AAAC,MAAMgB,KAAK;oBACVP,YAAYD,KAAKC,UAAU,EAAEC;oBAC7BO,SAASlB,IAAIkB,OAAO;oBACpBqC,KAAKtD;oBACLD;gBACF,MAAOC;YACX;QACF;QAEA,IAAIkF,SAA2D;YAC7DN;YACAC;YACA7E;QACF;QAEA,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCkF,SAAS,MAAMtG,oBAAoB;YACjC4B;YACAC,YAAYD,KAAKC,UAAU,EAAEC;YAC7BQ,WAAW;YACXgE;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAOA;IACT,EAAE,OAAOC,OAAgB;QACvB,MAAMhG,gBAAgBqB,KAAKT,GAAG;QAC9B,MAAMoF;IACR;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/operations/login.ts"],"sourcesContent":["import { v4 as uuid } from 'uuid'\n\nimport type {\n AuthOperationsFromCollectionSlug,\n Collection,\n DataFromCollectionSlug,\n} from '../../collections/config/types.js'\nimport type { CollectionSlug, TypedUser } from '../../index.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\n\nimport { buildAfterOperation } from '../../collections/operations/utils.js'\nimport {\n AuthenticationError,\n LockedAuth,\n UnverifiedEmail,\n ValidationError,\n} from '../../errors/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { Forbidden } from '../../index.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { sanitizeInternalFields } from '../../utilities/sanitizeInternalFields.js'\nimport { getFieldsToSign } from '../getFieldsToSign.js'\nimport { getLoginOptions } from '../getLoginOptions.js'\nimport { isUserLocked } from '../isUserLocked.js'\nimport { jwtSign } from '../jwt.js'\nimport { removeExpiredSessions } from '../removeExpiredSessions.js'\nimport { authenticateLocalStrategy } from '../strategies/local/authenticate.js'\nimport { incrementLoginAttempts } from '../strategies/local/incrementLoginAttempts.js'\nimport { resetLoginAttempts } from '../strategies/local/resetLoginAttempts.js'\n\nexport type Result = {\n exp?: number\n token?: string\n user?: TypedUser\n}\n\nexport type Arguments<TSlug extends CollectionSlug> = {\n collection: Collection\n data: AuthOperationsFromCollectionSlug<TSlug>['login']\n depth?: number\n overrideAccess?: boolean\n req: PayloadRequest\n showHiddenFields?: boolean\n}\n\ntype CheckLoginPermissionArgs = {\n loggingInWithUsername?: boolean\n req: PayloadRequest\n user: any\n}\n\nexport const checkLoginPermission = ({\n loggingInWithUsername,\n req,\n user,\n}: CheckLoginPermissionArgs) => {\n if (!user) {\n throw new AuthenticationError(req.t, Boolean(loggingInWithUsername))\n }\n\n if (isUserLocked(new Date(user.lockUntil).getTime())) {\n throw new LockedAuth(req.t)\n }\n}\n\nexport const loginOperation = async <TSlug extends CollectionSlug>(\n incomingArgs: Arguments<TSlug>,\n): Promise<{ user: DataFromCollectionSlug<TSlug> } & Result> => {\n let args = incomingArgs\n\n if (args.collection.config.auth.disableLocalStrategy) {\n throw new Forbidden(args.req.t)\n }\n\n try {\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n if (args.collection.config.hooks?.beforeOperation?.length) {\n for (const hook of args.collection.config.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n collection: args.collection?.config,\n context: args.req.context,\n operation: 'login',\n req: args.req,\n })) || args\n }\n }\n\n const {\n collection: { config: collectionConfig },\n data,\n depth,\n overrideAccess,\n req,\n req: {\n fallbackLocale,\n locale,\n payload,\n payload: { secret },\n },\n showHiddenFields,\n } = args\n\n // /////////////////////////////////////\n // Login\n // /////////////////////////////////////\n\n const { email: unsanitizedEmail, password } = data\n const loginWithUsername = collectionConfig.auth.loginWithUsername\n\n const sanitizedEmail =\n typeof unsanitizedEmail === 'string' ? unsanitizedEmail.toLowerCase().trim() : null\n const sanitizedUsername =\n 'username' in data && typeof data?.username === 'string'\n ? data.username.toLowerCase().trim()\n : null\n\n const { canLoginWithEmail, canLoginWithUsername } = getLoginOptions(loginWithUsername)\n\n // cannot login with email, did not provide username\n if (!canLoginWithEmail && !sanitizedUsername) {\n throw new ValidationError({\n collection: collectionConfig.slug,\n errors: [{ message: req.i18n.t('validation:required'), path: 'username' }],\n })\n }\n\n // cannot login with username, did not provide email\n if (!canLoginWithUsername && !sanitizedEmail) {\n throw new ValidationError({\n collection: collectionConfig.slug,\n errors: [{ message: req.i18n.t('validation:required'), path: 'email' }],\n })\n }\n\n // can login with either email or username, did not provide either\n if (!sanitizedUsername && !sanitizedEmail) {\n throw new ValidationError({\n collection: collectionConfig.slug,\n errors: [\n { message: req.i18n.t('validation:required'), path: 'email' },\n { message: req.i18n.t('validation:required'), path: 'username' },\n ],\n })\n }\n\n // did not provide password for login\n if (typeof password !== 'string' || password.trim() === '') {\n throw new ValidationError({\n collection: collectionConfig.slug,\n errors: [{ message: req.i18n.t('validation:required'), path: 'password' }],\n })\n }\n\n let whereConstraint: Where = {}\n const emailConstraint: Where = {\n email: {\n equals: sanitizedEmail,\n },\n }\n const usernameConstraint: Where = {\n username: {\n equals: sanitizedUsername,\n },\n }\n\n if (canLoginWithEmail && canLoginWithUsername && (sanitizedUsername || sanitizedEmail)) {\n if (sanitizedUsername) {\n whereConstraint = {\n or: [\n usernameConstraint,\n {\n email: {\n equals: sanitizedUsername,\n },\n },\n ],\n }\n } else {\n whereConstraint = {\n or: [\n emailConstraint,\n {\n username: {\n equals: sanitizedEmail,\n },\n },\n ],\n }\n }\n } else if (canLoginWithEmail && sanitizedEmail) {\n whereConstraint = emailConstraint\n } else if (canLoginWithUsername && sanitizedUsername) {\n whereConstraint = usernameConstraint\n }\n\n let user = await payload.db.findOne<any>({\n collection: collectionConfig.slug,\n req,\n where: whereConstraint,\n })\n\n checkLoginPermission({\n loggingInWithUsername: Boolean(canLoginWithUsername && sanitizedUsername),\n req,\n user,\n })\n\n user.collection = collectionConfig.slug\n user._strategy = 'local-jwt'\n\n const authResult = await authenticateLocalStrategy({ doc: user, password })\n user = sanitizeInternalFields(user)\n\n const maxLoginAttemptsEnabled = args.collection.config.auth.maxLoginAttempts > 0\n\n if (!authResult) {\n if (maxLoginAttemptsEnabled) {\n await incrementLoginAttempts({\n collection: collectionConfig,\n doc: user,\n payload: req.payload,\n req,\n })\n }\n\n throw new AuthenticationError(req.t)\n }\n\n if (collectionConfig.auth.verify && user._verified === false) {\n throw new UnverifiedEmail({ t: req.t })\n }\n\n const fieldsToSignArgs: Parameters<typeof getFieldsToSign>[0] = {\n collectionConfig,\n email: sanitizedEmail!,\n user,\n }\n\n if (collectionConfig.auth.useSessions) {\n // Add session to user\n const newSessionID = uuid()\n const now = new Date()\n const tokenExpInMs = collectionConfig.auth.tokenExpiration * 1000\n const expiresAt = new Date(now.getTime() + tokenExpInMs)\n\n const session = { id: newSessionID, createdAt: now, expiresAt }\n\n if (!user.sessions?.length) {\n user.sessions = [session]\n } else {\n user.sessions = removeExpiredSessions(user.sessions)\n user.sessions.push(session)\n }\n\n await payload.db.updateOne({\n id: user.id,\n collection: collectionConfig.slug,\n data: user,\n req,\n returning: false,\n })\n\n user.collection = collectionConfig.slug\n user._strategy = 'local-jwt'\n\n fieldsToSignArgs.sid = newSessionID\n }\n\n const fieldsToSign = getFieldsToSign(fieldsToSignArgs)\n\n if (maxLoginAttemptsEnabled) {\n await resetLoginAttempts({\n collection: collectionConfig,\n doc: user,\n payload: req.payload,\n req,\n })\n }\n\n // /////////////////////////////////////\n // beforeLogin - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeLogin?.length) {\n for (const hook of collectionConfig.hooks.beforeLogin) {\n user =\n (await hook({\n collection: args.collection?.config,\n context: args.req.context,\n req: args.req,\n user,\n })) || user\n }\n }\n\n const { exp, token } = await jwtSign({\n fieldsToSign,\n secret,\n tokenExpiration: collectionConfig.auth.tokenExpiration,\n })\n\n req.user = user\n\n // /////////////////////////////////////\n // afterLogin - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterLogin?.length) {\n for (const hook of collectionConfig.hooks.afterLogin) {\n user =\n (await hook({\n collection: args.collection?.config,\n context: args.req.context,\n req: args.req,\n token,\n user,\n })) || user\n }\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n user = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth: depth!,\n doc: user,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n draft: undefined,\n fallbackLocale: fallbackLocale!,\n global: null,\n locale: locale!,\n overrideAccess: overrideAccess!,\n req,\n showHiddenFields: showHiddenFields!,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterRead?.length) {\n for (const hook of collectionConfig.hooks.afterRead) {\n user =\n (await hook({\n collection: args.collection?.config,\n context: req.context,\n doc: user,\n req,\n })) || user\n }\n }\n\n let result: { user: DataFromCollectionSlug<TSlug> } & Result = {\n exp,\n token,\n user,\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: args.collection?.config,\n operation: 'login',\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["v4","uuid","buildAfterOperation","AuthenticationError","LockedAuth","UnverifiedEmail","ValidationError","afterRead","Forbidden","killTransaction","sanitizeInternalFields","getFieldsToSign","getLoginOptions","isUserLocked","jwtSign","removeExpiredSessions","authenticateLocalStrategy","incrementLoginAttempts","resetLoginAttempts","checkLoginPermission","loggingInWithUsername","req","user","t","Boolean","Date","lockUntil","getTime","loginOperation","incomingArgs","args","collection","config","auth","disableLocalStrategy","hooks","beforeOperation","length","hook","context","operation","collectionConfig","data","depth","overrideAccess","fallbackLocale","locale","payload","secret","showHiddenFields","email","unsanitizedEmail","password","loginWithUsername","sanitizedEmail","toLowerCase","trim","sanitizedUsername","username","canLoginWithEmail","canLoginWithUsername","slug","errors","message","i18n","path","whereConstraint","emailConstraint","equals","usernameConstraint","or","db","findOne","where","_strategy","authResult","doc","maxLoginAttemptsEnabled","maxLoginAttempts","verify","_verified","fieldsToSignArgs","useSessions","newSessionID","now","tokenExpInMs","tokenExpiration","expiresAt","session","id","createdAt","sessions","push","updateOne","returning","sid","fieldsToSign","beforeLogin","exp","token","afterLogin","draft","undefined","global","result","error"],"mappings":"AAAA,SAASA,MAAMC,IAAI,QAAQ,OAAM;AAUjC,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SACEC,mBAAmB,EACnBC,UAAU,EACVC,eAAe,EACfC,eAAe,QACV,wBAAuB;AAC9B,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SAASC,eAAe,QAAQ,wBAAuB;AACvD,SAASC,eAAe,QAAQ,wBAAuB;AACvD,SAASC,YAAY,QAAQ,qBAAoB;AACjD,SAASC,OAAO,QAAQ,YAAW;AACnC,SAASC,qBAAqB,QAAQ,8BAA6B;AACnE,SAASC,yBAAyB,QAAQ,sCAAqC;AAC/E,SAASC,sBAAsB,QAAQ,gDAA+C;AACtF,SAASC,kBAAkB,QAAQ,4CAA2C;AAuB9E,OAAO,MAAMC,uBAAuB,CAAC,EACnCC,qBAAqB,EACrBC,GAAG,EACHC,IAAI,EACqB;IACzB,IAAI,CAACA,MAAM;QACT,MAAM,IAAInB,oBAAoBkB,IAAIE,CAAC,EAAEC,QAAQJ;IAC/C;IAEA,IAAIP,aAAa,IAAIY,KAAKH,KAAKI,SAAS,EAAEC,OAAO,KAAK;QACpD,MAAM,IAAIvB,WAAWiB,IAAIE,CAAC;IA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S,MAAMtG,oBAAoB;YACjC4B;YACAC,YAAYD,KAAKC,UAAU,EAAEC;YAC7BQ,WAAW;YACXgE;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAOA;IACT,EAAE,OAAOC,OAAgB;QACvB,MAAMhG,gBAAgBqB,KAAKT,GAAG;QAC9B,MAAMoF;IACR;AACF,EAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Collection } from '../../collections/config/types.js';
|
|
2
|
-
import type { PayloadRequest } from '../../types/index.js';
|
|
2
|
+
import type { JoinQuery, PayloadRequest, PopulateType, SelectType } from '../../types/index.js';
|
|
3
3
|
import type { ClientUser } from '../types.js';
|
|
4
4
|
export type MeOperationResult = {
|
|
5
5
|
collection?: string;
|
|
@@ -17,7 +17,12 @@ export type MeOperationResult = {
|
|
|
17
17
|
export type Arguments = {
|
|
18
18
|
collection: Collection;
|
|
19
19
|
currentToken?: string;
|
|
20
|
+
depth?: number;
|
|
21
|
+
draft?: boolean;
|
|
22
|
+
joins?: JoinQuery;
|
|
23
|
+
populate?: PopulateType;
|
|
20
24
|
req: PayloadRequest;
|
|
25
|
+
select?: SelectType;
|
|
21
26
|
};
|
|
22
27
|
export declare const meOperation: (args: Arguments) => Promise<MeOperationResult>;
|
|
23
28
|
//# sourceMappingURL=me.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/me.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/me.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAC/F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,WAAW,SAAgB,SAAS,KAAG,OAAO,CAAC,iBAAiB,CA2F5E,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { decodeJwt } from 'jose';
|
|
2
2
|
export const meOperation = async (args)=>{
|
|
3
|
-
const { collection, currentToken, req } = args;
|
|
3
|
+
const { collection, currentToken, depth, draft, joins, populate, req, select } = args;
|
|
4
4
|
let result = {
|
|
5
5
|
user: null
|
|
6
6
|
};
|
|
@@ -10,9 +10,13 @@ export const meOperation = async (args)=>{
|
|
|
10
10
|
const user = await req.payload.findByID({
|
|
11
11
|
id: req.user.id,
|
|
12
12
|
collection: collection.config.slug,
|
|
13
|
-
depth: isGraphQL ? 0 : collection.config.auth.depth,
|
|
13
|
+
depth: isGraphQL ? 0 : depth ?? collection.config.auth.depth,
|
|
14
|
+
draft,
|
|
15
|
+
joins,
|
|
14
16
|
overrideAccess: false,
|
|
17
|
+
populate,
|
|
15
18
|
req,
|
|
19
|
+
select,
|
|
16
20
|
showHiddenFields: false
|
|
17
21
|
});
|
|
18
22
|
if (user) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/auth/operations/me.ts"],"sourcesContent":["import { decodeJwt } from 'jose'\n\nimport type { Collection } from '../../collections/config/types.js'\nimport type { TypedUser } from '../../index.js'\nimport type { PayloadRequest } from '../../types/index.js'\nimport type { ClientUser } from '../types.js'\n\nexport type MeOperationResult = {\n collection?: string\n exp?: number\n /** @deprecated\n * use:\n * ```ts\n * user._strategy\n * ```\n */\n strategy?: string\n token?: string\n user?: ClientUser\n}\n\nexport type Arguments = {\n collection: Collection\n currentToken?: string\n req: PayloadRequest\n}\n\nexport const meOperation = async (args: Arguments): Promise<MeOperationResult> => {\n const { collection, currentToken, req } = args\n\n let result: MeOperationResult = {\n user: null!,\n }\n\n if (req.user) {\n const { pathname } = req\n const isGraphQL = pathname === `/api${req.payload.config.routes.graphQL}`\n\n const user = (await req.payload.findByID({\n id: req.user.id,\n collection: collection.config.slug,\n depth: isGraphQL ? 0 : collection.config.auth.depth,\n overrideAccess: false,\n req,\n showHiddenFields: false,\n })) as TypedUser\n\n if (user) {\n user.collection = collection.config.slug\n user._strategy = req.user._strategy\n }\n\n if (req.user.collection !== collection.config.slug) {\n return {\n user: null!,\n }\n }\n\n // /////////////////////////////////////\n // me hook - Collection\n // /////////////////////////////////////\n\n for (const meHook of collection.config.hooks.me) {\n const hookResult = await meHook({ args, user })\n\n if (hookResult) {\n result.user = hookResult.user\n result.exp = hookResult.exp\n\n break\n }\n }\n\n result.collection = req.user.collection\n /** @deprecated\n * use:\n * ```ts\n * user._strategy\n * ```\n */\n result.strategy = req.user._strategy\n\n if (!result.user) {\n result.user = user\n\n if (currentToken) {\n const decoded = decodeJwt(currentToken)\n if (decoded) {\n result.exp = decoded.exp\n }\n if (!collection.config.auth.removeTokenFromResponses) {\n result.token = currentToken\n }\n }\n }\n }\n\n // /////////////////////////////////////\n // After Me - Collection\n // /////////////////////////////////////\n\n if (collection.config.hooks?.afterMe?.length) {\n for (const hook of collection.config.hooks.afterMe) {\n result =\n (await hook({\n collection: collection?.config,\n context: req.context,\n req,\n response: result,\n })) || result\n }\n }\n\n return result\n}\n"],"names":["decodeJwt","meOperation","args","collection","currentToken","req","result","user","pathname","isGraphQL","payload","config","routes","graphQL","findByID","id","slug","
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/operations/me.ts"],"sourcesContent":["import { decodeJwt } from 'jose'\n\nimport type { Collection } from '../../collections/config/types.js'\nimport type { TypedUser } from '../../index.js'\nimport type { JoinQuery, PayloadRequest, PopulateType, SelectType } from '../../types/index.js'\nimport type { ClientUser } from '../types.js'\n\nexport type MeOperationResult = {\n collection?: string\n exp?: number\n /** @deprecated\n * use:\n * ```ts\n * user._strategy\n * ```\n */\n strategy?: string\n token?: string\n user?: ClientUser\n}\n\nexport type Arguments = {\n collection: Collection\n currentToken?: string\n depth?: number\n draft?: boolean\n joins?: JoinQuery\n populate?: PopulateType\n req: PayloadRequest\n select?: SelectType\n}\n\nexport const meOperation = async (args: Arguments): Promise<MeOperationResult> => {\n const { collection, currentToken, depth, draft, joins, populate, req, select } = args\n\n let result: MeOperationResult = {\n user: null!,\n }\n\n if (req.user) {\n const { pathname } = req\n const isGraphQL = pathname === `/api${req.payload.config.routes.graphQL}`\n\n const user = (await req.payload.findByID({\n id: req.user.id,\n collection: collection.config.slug,\n depth: isGraphQL ? 0 : (depth ?? collection.config.auth.depth),\n draft,\n joins,\n overrideAccess: false,\n populate,\n req,\n select,\n showHiddenFields: false,\n })) as TypedUser\n\n if (user) {\n user.collection = collection.config.slug\n user._strategy = req.user._strategy\n }\n\n if (req.user.collection !== collection.config.slug) {\n return {\n user: null!,\n }\n }\n\n // /////////////////////////////////////\n // me hook - Collection\n // /////////////////////////////////////\n\n for (const meHook of collection.config.hooks.me) {\n const hookResult = await meHook({ args, user })\n\n if (hookResult) {\n result.user = hookResult.user\n result.exp = hookResult.exp\n\n break\n }\n }\n\n result.collection = req.user.collection\n /** @deprecated\n * use:\n * ```ts\n * user._strategy\n * ```\n */\n result.strategy = req.user._strategy\n\n if (!result.user) {\n result.user = user\n\n if (currentToken) {\n const decoded = decodeJwt(currentToken)\n if (decoded) {\n result.exp = decoded.exp\n }\n if (!collection.config.auth.removeTokenFromResponses) {\n result.token = currentToken\n }\n }\n }\n }\n\n // /////////////////////////////////////\n // After Me - Collection\n // /////////////////////////////////////\n\n if (collection.config.hooks?.afterMe?.length) {\n for (const hook of collection.config.hooks.afterMe) {\n result =\n (await hook({\n collection: collection?.config,\n context: req.context,\n req,\n response: result,\n })) || result\n }\n }\n\n return result\n}\n"],"names":["decodeJwt","meOperation","args","collection","currentToken","depth","draft","joins","populate","req","select","result","user","pathname","isGraphQL","payload","config","routes","graphQL","findByID","id","slug","auth","overrideAccess","showHiddenFields","_strategy","meHook","hooks","me","hookResult","exp","strategy","decoded","removeTokenFromResponses","token","afterMe","length","hook","context","response"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAM;AAgChC,OAAO,MAAMC,cAAc,OAAOC;IAChC,MAAM,EAAEC,UAAU,EAAEC,YAAY,EAAEC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,GAAG,EAAEC,MAAM,EAAE,GAAGR;IAEjF,IAAIS,SAA4B;QAC9BC,MAAM;IACR;IAEA,IAAIH,IAAIG,IAAI,EAAE;QACZ,MAAM,EAAEC,QAAQ,EAAE,GAAGJ;QACrB,MAAMK,YAAYD,aAAa,CAAC,IAAI,EAAEJ,IAAIM,OAAO,CAACC,MAAM,CAACC,MAAM,CAACC,OAAO,EAAE;QAEzE,MAAMN,OAAQ,MAAMH,IAAIM,OAAO,CAACI,QAAQ,CAAC;YACvCC,IAAIX,IAAIG,IAAI,CAACQ,EAAE;YACfjB,YAAYA,WAAWa,MAAM,CAACK,IAAI;YAClChB,OAAOS,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C,QAAQlC,WAAWa,MAAM,CAACW,KAAK,CAACQ,OAAO,CAAE;YAClDxB,SACE,AAAC,MAAM0B,KAAK;gBACVlC,YAAYA,YAAYa;gBACxBsB,SAAS7B,IAAI6B,OAAO;gBACpB7B;gBACA8B,UAAU5B;YACZ,MAAOA;QACX;IACF;IAEA,OAAOA;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resetLoginAttempts.d.ts","sourceRoot":"","sources":["../../../../src/auth/strategies/local/resetLoginAttempts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAA;AACjG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAE7D,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,yBAAyB,CAAA;IACrC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,CAAA;IACzC,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,kBAAkB,uCAK5B,IAAI,KAAG,OAAO,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"resetLoginAttempts.d.ts","sourceRoot":"","sources":["../../../../src/auth/strategies/local/resetLoginAttempts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAA;AACjG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAE7D,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,yBAAyB,CAAA;IACrC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,CAAA;IACzC,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,kBAAkB,uCAK5B,IAAI,KAAG,OAAO,CAAC,IAAI,CAkBrB,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const resetLoginAttempts = async ({ collection, doc, payload, req })=>{
|
|
2
|
-
if (!('lockUntil' in doc && typeof doc.lockUntil === 'string') || doc.loginAttempts === 0) {
|
|
2
|
+
if (!('lockUntil' in doc && typeof doc.lockUntil === 'string') && (!('loginAttempts' in doc) || doc.loginAttempts === 0)) {
|
|
3
3
|
return;
|
|
4
4
|
}
|
|
5
5
|
await payload.update({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/auth/strategies/local/resetLoginAttempts.ts"],"sourcesContent":["import type { SanitizedCollectionConfig, TypeWithID } from '../../../collections/config/types.js'\nimport type { Payload } from '../../../index.js'\nimport type { PayloadRequest } from '../../../types/index.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig\n doc: Record<string, unknown> & TypeWithID\n payload: Payload\n req: PayloadRequest\n}\n\nexport const resetLoginAttempts = async ({\n collection,\n doc,\n payload,\n req,\n}: Args): Promise<void> => {\n if (!('lockUntil' in doc && typeof doc.lockUntil === 'string') || doc.loginAttempts === 0) {\n return\n }\n await payload.update({\n id: doc.id,\n collection: collection.slug,\n data: {\n lockUntil: null,\n loginAttempts: 0,\n },\n depth: 0,\n overrideAccess: true,\n req,\n })\n}\n"],"names":["resetLoginAttempts","collection","doc","payload","req","lockUntil","loginAttempts","update","id","slug","data","depth","overrideAccess"],"mappings":"AAWA,OAAO,MAAMA,qBAAqB,OAAO,EACvCC,UAAU,EACVC,GAAG,EACHC,OAAO,EACPC,GAAG,EACE;IACL,
|
|
1
|
+
{"version":3,"sources":["../../../../src/auth/strategies/local/resetLoginAttempts.ts"],"sourcesContent":["import type { SanitizedCollectionConfig, TypeWithID } from '../../../collections/config/types.js'\nimport type { Payload } from '../../../index.js'\nimport type { PayloadRequest } from '../../../types/index.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig\n doc: Record<string, unknown> & TypeWithID\n payload: Payload\n req: PayloadRequest\n}\n\nexport const resetLoginAttempts = async ({\n collection,\n doc,\n payload,\n req,\n}: Args): Promise<void> => {\n if (\n !('lockUntil' in doc && typeof doc.lockUntil === 'string') &&\n (!('loginAttempts' in doc) || doc.loginAttempts === 0)\n ) {\n return\n }\n await payload.update({\n id: doc.id,\n collection: collection.slug,\n data: {\n lockUntil: null,\n loginAttempts: 0,\n },\n depth: 0,\n overrideAccess: true,\n req,\n })\n}\n"],"names":["resetLoginAttempts","collection","doc","payload","req","lockUntil","loginAttempts","update","id","slug","data","depth","overrideAccess"],"mappings":"AAWA,OAAO,MAAMA,qBAAqB,OAAO,EACvCC,UAAU,EACVC,GAAG,EACHC,OAAO,EACPC,GAAG,EACE;IACL,IACE,CAAE,CAAA,eAAeF,OAAO,OAAOA,IAAIG,SAAS,KAAK,QAAO,KACvD,CAAA,CAAE,CAAA,mBAAmBH,GAAE,KAAMA,IAAII,aAAa,KAAK,CAAA,GACpD;QACA;IACF;IACA,MAAMH,QAAQI,MAAM,CAAC;QACnBC,IAAIN,IAAIM,EAAE;QACVP,YAAYA,WAAWQ,IAAI;QAC3BC,MAAM;YACJL,WAAW;YACXC,eAAe;QACjB;QACAK,OAAO;QACPC,gBAAgB;QAChBR;IACF;AACF,EAAC"}
|
package/dist/exports/shared.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export { isPlainObject } from '../utilities/isPlainObject.js';
|
|
|
36
36
|
export { isReactClientComponent, isReactComponentOrFunction, isReactServerComponentOrFunction, } from '../utilities/isReactComponent.js';
|
|
37
37
|
export { hoistQueryParamsToAnd, mergeListSearchAndWhere, } from '../utilities/mergeListSearchAndWhere.js';
|
|
38
38
|
export { reduceFieldsToValues } from '../utilities/reduceFieldsToValues.js';
|
|
39
|
+
export { sanitizeUserDataForEmail } from '../utilities/sanitizeUserDataForEmail.js';
|
|
39
40
|
export { setsAreEqual } from '../utilities/setsAreEqual.js';
|
|
40
41
|
export { toKebabCase } from '../utilities/toKebabCase.js';
|
|
41
42
|
export { transformColumnsToPreferences, transformColumnsToSearchParams, } from '../utilities/transformColumnPreferences.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/exports/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,4BAA4B,EAC5B,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,GACb,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAA;AACzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,6DAA6D,CAAA;AACnG,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAA;AAEpF,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,SAAS,EACT,gBAAgB,EAChB,yBAAyB,EACzB,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,wBAAwB,GACzB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,cAAc,0BAA0B,CAAA;AAExC,YAAY,EACV,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,SAAS,GACV,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAA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AC7B,8BAA8B,GAC/B,MAAM,4CAA4C,CAAA;AAEnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AAEzE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA"}
|
package/dist/exports/shared.js
CHANGED
|
@@ -35,6 +35,7 @@ export { isPlainObject } from '../utilities/isPlainObject.js';
|
|
|
35
35
|
export { isReactClientComponent, isReactComponentOrFunction, isReactServerComponentOrFunction } from '../utilities/isReactComponent.js';
|
|
36
36
|
export { hoistQueryParamsToAnd, mergeListSearchAndWhere } from '../utilities/mergeListSearchAndWhere.js';
|
|
37
37
|
export { reduceFieldsToValues } from '../utilities/reduceFieldsToValues.js';
|
|
38
|
+
export { sanitizeUserDataForEmail } from '../utilities/sanitizeUserDataForEmail.js';
|
|
38
39
|
export { setsAreEqual } from '../utilities/setsAreEqual.js';
|
|
39
40
|
export { toKebabCase } from '../utilities/toKebabCase.js';
|
|
40
41
|
export { transformColumnsToPreferences, transformColumnsToSearchParams } from '../utilities/transformColumnPreferences.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/shared.ts"],"sourcesContent":["export {\n generateCookie,\n generateExpiredPayloadCookie,\n generatePayloadCookie,\n getCookieExpiration,\n parseCookies,\n} from '../auth/cookies.js'\nexport { getLoginOptions } from '../auth/getLoginOptions.js'\nexport { getFromImportMap } from '../bin/generateImportMap/utilities/getFromImportMap.js'\nexport { parsePayloadComponent } from '../bin/generateImportMap/utilities/parsePayloadComponent.js'\nexport { defaults as collectionDefaults } from '../collections/config/defaults.js'\n\nexport { serverProps } from '../config/types.js'\n\nexport { defaultTimezones } from '../fields/baseFields/timezone/defaultTimezones.js'\n\nexport {\n fieldAffectsData,\n fieldHasMaxDepth,\n fieldHasSubFields,\n fieldIsArrayType,\n fieldIsBlockType,\n fieldIsGroupType,\n fieldIsHiddenOrDisabled,\n fieldIsID,\n fieldIsLocalized,\n fieldIsPresentationalOnly,\n fieldIsSidebar,\n fieldIsVirtual,\n fieldShouldBeLocalized,\n fieldSupportsMany,\n groupHasName,\n optionIsObject,\n optionIsValue,\n optionsAreObjects,\n tabHasName,\n valueIsValueWithRelation,\n} from '../fields/config/types.js'\n\nexport { getFieldPaths } from '../fields/getFieldPaths.js'\nexport * from '../fields/validations.js'\n\nexport type {\n FolderBreadcrumb,\n FolderDocumentItemKey,\n FolderEnabledColection,\n FolderInterface,\n FolderOrDocument,\n GetFolderDataResult,\n Subfolder,\n} from '../folders/types.js'\n\nexport { buildFolderWhereConstraints } from '../folders/utils/buildFolderWhereConstraints.js'\nexport { formatFolderOrDocumentItem } from '../folders/utils/formatFolderOrDocumentItem.js'\nexport { validOperators, validOperatorSet } from '../types/constants.js'\n\nexport { formatFilesize } from '../uploads/formatFilesize.js'\n\nexport { isImage } from '../uploads/isImage.js'\nexport { combineWhereConstraints } from '../utilities/combineWhereConstraints.js'\n\nexport {\n deepCopyObject,\n deepCopyObjectComplex,\n deepCopyObjectSimple,\n deepCopyObjectSimpleWithoutReactComponents,\n} from '../utilities/deepCopyObject.js'\nexport {\n deepMerge,\n deepMergeWithCombinedArrays,\n deepMergeWithReactComponents,\n deepMergeWithSourceArrays,\n} from '../utilities/deepMerge.js'\n\nexport { extractID } from '../utilities/extractID.js'\n\nexport { fieldSchemaToJSON } from '../utilities/fieldSchemaToJSON.js'\n\nexport { flattenAllFields } from '../utilities/flattenAllFields.js'\nexport { flattenTopLevelFields } from '../utilities/flattenTopLevelFields.js'\nexport { formatAdminURL } from '../utilities/formatAdminURL.js'\n\nexport { formatLabels, toWords } from '../utilities/formatLabels.js'\nexport { getBestFitFromSizes } from '../utilities/getBestFitFromSizes.js'\nexport { getDataByPath } from '../utilities/getDataByPath.js'\nexport { getFieldPermissions } from '../utilities/getFieldPermissions.js'\n\nexport { getSafeRedirect } from '../utilities/getSafeRedirect.js'\n\nexport { getSelectMode } from '../utilities/getSelectMode.js'\n\nexport { getSiblingData } from '../utilities/getSiblingData.js'\n\nexport { getUniqueListBy } from '../utilities/getUniqueListBy.js'\n\nexport { isNextBuild } from '../utilities/isNextBuild.js'\n\nexport { isNumber } from '../utilities/isNumber.js'\n\nexport { isPlainObject } from '../utilities/isPlainObject.js'\n\nexport {\n isReactClientComponent,\n isReactComponentOrFunction,\n isReactServerComponentOrFunction,\n} from '../utilities/isReactComponent.js'\n\nexport {\n hoistQueryParamsToAnd,\n mergeListSearchAndWhere,\n} from '../utilities/mergeListSearchAndWhere.js'\n\nexport { reduceFieldsToValues } from '../utilities/reduceFieldsToValues.js'\n\nexport { setsAreEqual } from '../utilities/setsAreEqual.js'\n\nexport { toKebabCase } from '../utilities/toKebabCase.js'\n\nexport {\n transformColumnsToPreferences,\n transformColumnsToSearchParams,\n} from '../utilities/transformColumnPreferences.js'\n\nexport { transformWhereQuery } from '../utilities/transformWhereQuery.js'\n\nexport { unflatten } from '../utilities/unflatten.js'\nexport { validateMimeType } from '../utilities/validateMimeType.js'\nexport { validateWhereQuery } from '../utilities/validateWhereQuery.js'\nexport { wait } from '../utilities/wait.js'\nexport { wordBoundariesRegex } from '../utilities/wordBoundariesRegex.js'\nexport { versionDefaults } from '../versions/defaults.js'\n\nexport { deepMergeSimple } from '@payloadcms/translations/utilities'\n"],"names":["generateCookie","generateExpiredPayloadCookie","generatePayloadCookie","getCookieExpiration","parseCookies","getLoginOptions","getFromImportMap","parsePayloadComponent","defaults","collectionDefaults","serverProps","defaultTimezones","fieldAffectsData","fieldHasMaxDepth","fieldHasSubFields","fieldIsArrayType","fieldIsBlockType","fieldIsGroupType","fieldIsHiddenOrDisabled","fieldIsID","fieldIsLocalized","fieldIsPresentationalOnly","fieldIsSidebar","fieldIsVirtual","fieldShouldBeLocalized","fieldSupportsMany","groupHasName","optionIsObject","optionIsValue","optionsAreObjects","tabHasName","valueIsValueWithRelation","getFieldPaths","buildFolderWhereConstraints","formatFolderOrDocumentItem","validOperators","validOperatorSet","formatFilesize","isImage","combineWhereConstraints","deepCopyObject","deepCopyObjectComplex","deepCopyObjectSimple","deepCopyObjectSimpleWithoutReactComponents","deepMerge","deepMergeWithCombinedArrays","deepMergeWithReactComponents","deepMergeWithSourceArrays","extractID","fieldSchemaToJSON","flattenAllFields","flattenTopLevelFields","formatAdminURL","formatLabels","toWords","getBestFitFromSizes","getDataByPath","getFieldPermissions","getSafeRedirect","getSelectMode","getSiblingData","getUniqueListBy","isNextBuild","isNumber","isPlainObject","isReactClientComponent","isReactComponentOrFunction","isReactServerComponentOrFunction","hoistQueryParamsToAnd","mergeListSearchAndWhere","reduceFieldsToValues","setsAreEqual","toKebabCase","transformColumnsToPreferences","transformColumnsToSearchParams","transformWhereQuery","unflatten","validateMimeType","validateWhereQuery","wait","wordBoundariesRegex","versionDefaults","deepMergeSimple"],"mappings":"AAAA,SACEA,cAAc,EACdC,4BAA4B,EAC5BC,qBAAqB,EACrBC,mBAAmB,EACnBC,YAAY,QACP,qBAAoB;AAC3B,SAASC,eAAe,QAAQ,6BAA4B;AAC5D,SAASC,gBAAgB,QAAQ,yDAAwD;AACzF,SAASC,qBAAqB,QAAQ,8DAA6D;AACnG,SAASC,YAAYC,kBAAkB,QAAQ,oCAAmC;AAElF,SAASC,WAAW,QAAQ,qBAAoB;AAEhD,SAASC,gBAAgB,QAAQ,oDAAmD;AAEpF,SACEC,gBAAgB,EAChBC,gBAAgB,EAChBC,iBAAiB,EACjBC,gBAAgB,EAChBC,gBAAgB,EAChBC,gBAAgB,EAChBC,uBAAuB,EACvBC,SAAS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,0BAA0B,EAC1BC,gCAAgC,QAC3B,mCAAkC;AAEzC,SACEC,qBAAqB,EACrBC,uBAAuB,QAClB,0CAAyC;AAEhD,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,SAASC,YAAY,QAAQ,+BAA8B;AAE3D,SAASC,WAAW,QAAQ,8BAA6B;AAEzD,SACEC,6BAA6B,EAC7BC,8BAA8B,QACzB,6CAA4C;AAEnD,SAASC,mBAAmB,QAAQ,sCAAqC;AAEzE,SAASC,SAAS,QAAQ,4BAA2B;AACrD,SAASC,gBAAgB,QAAQ,mCAAkC;AACnE,SAASC,kBAAkB,QAAQ,qCAAoC;AACvE,SAASC,IAAI,QAAQ,uBAAsB;AAC3C,SAASC,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,SAASC,eAAe,QAAQ,qCAAoC"}
|
|
1
|
+
{"version":3,"sources":["../../src/exports/shared.ts"],"sourcesContent":["export {\n generateCookie,\n generateExpiredPayloadCookie,\n generatePayloadCookie,\n getCookieExpiration,\n parseCookies,\n} from '../auth/cookies.js'\nexport { getLoginOptions } from '../auth/getLoginOptions.js'\nexport { getFromImportMap } from '../bin/generateImportMap/utilities/getFromImportMap.js'\nexport { parsePayloadComponent } from '../bin/generateImportMap/utilities/parsePayloadComponent.js'\nexport { defaults as collectionDefaults } from '../collections/config/defaults.js'\n\nexport { serverProps } from '../config/types.js'\n\nexport { defaultTimezones } from '../fields/baseFields/timezone/defaultTimezones.js'\n\nexport {\n fieldAffectsData,\n fieldHasMaxDepth,\n fieldHasSubFields,\n fieldIsArrayType,\n fieldIsBlockType,\n fieldIsGroupType,\n fieldIsHiddenOrDisabled,\n fieldIsID,\n fieldIsLocalized,\n fieldIsPresentationalOnly,\n fieldIsSidebar,\n fieldIsVirtual,\n fieldShouldBeLocalized,\n fieldSupportsMany,\n groupHasName,\n optionIsObject,\n optionIsValue,\n optionsAreObjects,\n tabHasName,\n valueIsValueWithRelation,\n} from '../fields/config/types.js'\n\nexport { getFieldPaths } from '../fields/getFieldPaths.js'\nexport * from '../fields/validations.js'\n\nexport type {\n FolderBreadcrumb,\n FolderDocumentItemKey,\n FolderEnabledColection,\n FolderInterface,\n FolderOrDocument,\n GetFolderDataResult,\n Subfolder,\n} from '../folders/types.js'\n\nexport { buildFolderWhereConstraints } from '../folders/utils/buildFolderWhereConstraints.js'\nexport { formatFolderOrDocumentItem } from '../folders/utils/formatFolderOrDocumentItem.js'\nexport { validOperators, validOperatorSet } from '../types/constants.js'\n\nexport { formatFilesize } from '../uploads/formatFilesize.js'\n\nexport { isImage } from '../uploads/isImage.js'\nexport { combineWhereConstraints } from '../utilities/combineWhereConstraints.js'\n\nexport {\n deepCopyObject,\n deepCopyObjectComplex,\n deepCopyObjectSimple,\n deepCopyObjectSimpleWithoutReactComponents,\n} from '../utilities/deepCopyObject.js'\nexport {\n deepMerge,\n deepMergeWithCombinedArrays,\n deepMergeWithReactComponents,\n deepMergeWithSourceArrays,\n} from '../utilities/deepMerge.js'\n\nexport { extractID } from '../utilities/extractID.js'\n\nexport { fieldSchemaToJSON } from '../utilities/fieldSchemaToJSON.js'\n\nexport { flattenAllFields } from '../utilities/flattenAllFields.js'\nexport { flattenTopLevelFields } from '../utilities/flattenTopLevelFields.js'\nexport { formatAdminURL } from '../utilities/formatAdminURL.js'\n\nexport { formatLabels, toWords } from '../utilities/formatLabels.js'\nexport { getBestFitFromSizes } from '../utilities/getBestFitFromSizes.js'\nexport { getDataByPath } from '../utilities/getDataByPath.js'\nexport { getFieldPermissions } from '../utilities/getFieldPermissions.js'\n\nexport { getSafeRedirect } from '../utilities/getSafeRedirect.js'\n\nexport { getSelectMode } from '../utilities/getSelectMode.js'\n\nexport { getSiblingData } from '../utilities/getSiblingData.js'\n\nexport { getUniqueListBy } from '../utilities/getUniqueListBy.js'\n\nexport { isNextBuild } from '../utilities/isNextBuild.js'\n\nexport { isNumber } from '../utilities/isNumber.js'\n\nexport { isPlainObject } from '../utilities/isPlainObject.js'\n\nexport {\n isReactClientComponent,\n isReactComponentOrFunction,\n isReactServerComponentOrFunction,\n} from '../utilities/isReactComponent.js'\n\nexport {\n hoistQueryParamsToAnd,\n mergeListSearchAndWhere,\n} from '../utilities/mergeListSearchAndWhere.js'\n\nexport { reduceFieldsToValues } from '../utilities/reduceFieldsToValues.js'\n\nexport { sanitizeUserDataForEmail } from '../utilities/sanitizeUserDataForEmail.js'\n\nexport { setsAreEqual } from '../utilities/setsAreEqual.js'\n\nexport { toKebabCase } from '../utilities/toKebabCase.js'\n\nexport {\n transformColumnsToPreferences,\n transformColumnsToSearchParams,\n} from '../utilities/transformColumnPreferences.js'\n\nexport { transformWhereQuery } from '../utilities/transformWhereQuery.js'\n\nexport { unflatten } from '../utilities/unflatten.js'\nexport { validateMimeType } from '../utilities/validateMimeType.js'\nexport { validateWhereQuery } from '../utilities/validateWhereQuery.js'\nexport { wait } from '../utilities/wait.js'\nexport { wordBoundariesRegex } from '../utilities/wordBoundariesRegex.js'\nexport { versionDefaults } from '../versions/defaults.js'\n\nexport { deepMergeSimple } from '@payloadcms/translations/utilities'\n"],"names":["generateCookie","generateExpiredPayloadCookie","generatePayloadCookie","getCookieExpiration","parseCookies","getLoginOptions","getFromImportMap","parsePayloadComponent","defaults","collectionDefaults","serverProps","defaultTimezones","fieldAffectsData","fieldHasMaxDepth","fieldHasSubFields","fieldIsArrayType","fieldIsBlockType","fieldIsGroupType","fieldIsHiddenOrDisabled","fieldIsID","fieldIsLocalized","fieldIsPresentationalOnly","fieldIsSidebar","fieldIsVirtual","fieldShouldBeLocalized","fieldSupportsMany","groupHasName","optionIsObject","optionIsValue","optionsAreObjects","tabHasName","valueIsValueWithRelation","getFieldPaths","buildFolderWhereConstraints","formatFolderOrDocumentItem","validOperators","validOperatorSet","formatFilesize","isImage","combineWhereConstraints","deepCopyObject","deepCopyObjectComplex","deepCopyObjectSimple","deepCopyObjectSimpleWithoutReactComponents","deepMerge","deepMergeWithCombinedArrays","deepMergeWithReactComponents","deepMergeWithSourceArrays","extractID","fieldSchemaToJSON","flattenAllFields","flattenTopLevelFields","formatAdminURL","formatLabels","toWords","getBestFitFromSizes","getDataByPath","getFieldPermissions","getSafeRedirect","getSelectMode","getSiblingData","getUniqueListBy","isNextBuild","isNumber","isPlainObject","isReactClientComponent","isReactComponentOrFunction","isReactServerComponentOrFunction","hoistQueryParamsToAnd","mergeListSearchAndWhere","reduceFieldsToValues","sanitizeUserDataForEmail","setsAreEqual","toKebabCase","transformColumnsToPreferences","transformColumnsToSearchParams","transformWhereQuery","unflatten","validateMimeType","validateWhereQuery","wait","wordBoundariesRegex","versionDefaults","deepMergeSimple"],"mappings":"AAAA,SACEA,cAAc,EACdC,4BAA4B,EAC5BC,qBAAqB,EACrBC,mBAAmB,EACnBC,YAAY,QACP,qBAAoB;AAC3B,SAASC,eAAe,QAAQ,6BAA4B;AAC5D,SAASC,gBAAgB,QAAQ,yDAAwD;AACzF,SAASC,qBAAqB,QAAQ,8DAA6D;AACnG,SAASC,YAAYC,kBAAkB,QAAQ,oCAAmC;AAElF,SAASC,WAAW,QAAQ,qBAAoB;AAEhD,SAASC,gBAAgB,QAAQ,oDAAmD;AAEpF,SACEC,gBAAgB,EAChBC,gBAAgB,EAChBC,iBAAiB,EACjBC,gBAAgB,EAChBC,gBAAgB,EAChBC,gBAAgB,EAChBC,uBAAuB,EACvBC,SAAS,EACTC,gBAAgB,EAChBC,yBAAyB,EACzBC,cAAc,EACdC,cAAc,EACdC,sBAAsB,EACtBC,iBAAiB,EACjBC,YAAY,EACZC,cAAc,EACdC,aAAa,EACbC,iBAAiB,EACjBC,UAAU,EACVC,wBAAwB,QACnB,4BAA2B;AAElC,SAASC,aAAa,QAAQ,6BAA4B;AAC1D,cAAc,2BAA0B;AAYxC,SAASC,2BAA2B,QAAQ,kDAAiD;AAC7F,SAASC,0BAA0B,QAAQ,iDAAgD;AAC3F,SAASC,cAAc,EAAEC,gBAAgB,QAAQ,wBAAuB;AAExE,SAASC,cAAc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OAAO,EAAE,cAAc,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,UAAU,CAAA;IACf,KAAK,EAAE,OAAO,CAAA;IACd,cAAc,EAAE,IAAI,GAAG,MAAM,CAAA;IAC7B,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,IAAI,GAAG,qBAAqB,CAAA;IACpC,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,cAAc,EAAE,OAAO,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IACnC,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,gBAAgB,EAAE,OAAO,CAAA;IACzB,UAAU,EAAE,UAAU,CAAA;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IACtC,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAUD,eAAO,MAAM,OAAO,+XA+BjB,IAAI,KAAG,OAAO,CAAC,IAAI,CA8wBrB,CAAA"}
|
|
@@ -25,7 +25,9 @@ export const promise = async ({ blockData, collection, context, currentDepth, de
|
|
|
25
25
|
const pathSegments = path ? path.split('.') : [];
|
|
26
26
|
const schemaPathSegments = schemaPath ? schemaPath.split('.') : [];
|
|
27
27
|
const indexPathSegments = indexPath ? indexPath.split('-').filter(Boolean)?.map(Number) : [];
|
|
28
|
+
let removedFieldValue = false;
|
|
28
29
|
if (fieldAffectsData(field) && field.hidden && typeof siblingDoc[field.name] !== 'undefined' && !showHiddenFields) {
|
|
30
|
+
removedFieldValue = true;
|
|
29
31
|
delete siblingDoc[field.name];
|
|
30
32
|
}
|
|
31
33
|
if (path !== 'id') {
|
|
@@ -205,7 +207,7 @@ export const promise = async ({ blockData, collection, context, currentDepth, de
|
|
|
205
207
|
// Execute access control
|
|
206
208
|
let allowDefaultValue = true;
|
|
207
209
|
if (triggerAccessControl && field.access && field.access.read) {
|
|
208
|
-
const
|
|
210
|
+
const canReadField = overrideAccess ? true : await field.access.read({
|
|
209
211
|
id: doc.id,
|
|
210
212
|
blockData,
|
|
211
213
|
data: doc,
|
|
@@ -213,14 +215,14 @@ export const promise = async ({ blockData, collection, context, currentDepth, de
|
|
|
213
215
|
req,
|
|
214
216
|
siblingData: siblingDoc
|
|
215
217
|
});
|
|
216
|
-
if (!
|
|
218
|
+
if (!canReadField) {
|
|
217
219
|
allowDefaultValue = false;
|
|
218
220
|
delete siblingDoc[field.name];
|
|
219
221
|
}
|
|
220
222
|
}
|
|
221
223
|
// Set defaultValue on the field for globals being returned without being first created
|
|
222
224
|
// or collection documents created prior to having a default
|
|
223
|
-
if (allowDefaultValue && typeof siblingDoc[field.name] === 'undefined' && typeof field.defaultValue !== 'undefined') {
|
|
225
|
+
if (!removedFieldValue && allowDefaultValue && typeof siblingDoc[field.name] === 'undefined' && typeof field.defaultValue !== 'undefined') {
|
|
224
226
|
siblingDoc[field.name] = await getDefaultValue({
|
|
225
227
|
defaultValue: field.defaultValue,
|
|
226
228
|
locale: locale,
|