Files
klz-cables.com/.pnpm-store/v10/files/f0/35a92f356a16debd7d48a4b277a722891d2fd621cbbaed92f5c73a40f889b21958b344e2a9bb618ac74b27c220f3b781d822b743c6550f5b21dffb125d2bbb
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

1 line
4.1 KiB
Plaintext

{"version":3,"sources":["../../../../src/auth/strategies/local/register.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { JsonObject, Payload } from '../../../index.js'\nimport type { PayloadRequest, SelectType, Where } from '../../../types/index.js'\n\nimport { ValidationError } from '../../../errors/index.js'\nimport { getLoginOptions } from '../../getLoginOptions.js'\nimport { generatePasswordSaltHash } from './generatePasswordSaltHash.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig\n doc: JsonObject\n password: string\n payload: Payload\n req: PayloadRequest\n}\n\nexport const registerLocalStrategy = async ({\n collection,\n doc,\n password,\n payload,\n req,\n}: Args): Promise<Record<string, unknown>> => {\n const loginWithUsername = collection?.auth?.loginWithUsername\n\n const { canLoginWithEmail, canLoginWithUsername } = getLoginOptions(loginWithUsername)\n\n let whereConstraint: Where\n\n if (!canLoginWithUsername) {\n whereConstraint = {\n email: {\n equals: doc.email,\n },\n }\n } else {\n whereConstraint = {\n or: [],\n }\n\n if (canLoginWithEmail && doc.email) {\n whereConstraint.or?.push({\n email: {\n equals: doc.email,\n },\n })\n }\n\n if (doc.username) {\n whereConstraint.or?.push({\n username: {\n equals: doc.username,\n },\n })\n }\n }\n\n const existingUser = await payload.find({\n collection: collection.slug,\n depth: 0,\n limit: 1,\n pagination: false,\n req,\n where: whereConstraint,\n })\n\n if (existingUser.docs.length > 0) {\n throw new ValidationError({\n collection: collection.slug,\n errors: [\n canLoginWithUsername\n ? {\n message: req.t('error:usernameAlreadyRegistered'),\n path: 'username',\n }\n : { message: req.t('error:userEmailAlreadyRegistered'), path: 'email' },\n ],\n })\n }\n\n const { hash, salt } = await generatePasswordSaltHash({ collection, password, req })\n\n const sanitizedDoc = { ...doc }\n if (sanitizedDoc.password) {\n delete sanitizedDoc.password\n }\n\n return payload.db.create({\n collection: collection.slug,\n data: {\n ...sanitizedDoc,\n hash,\n salt,\n },\n req,\n })\n}\n"],"names":["ValidationError","getLoginOptions","generatePasswordSaltHash","registerLocalStrategy","collection","doc","password","payload","req","loginWithUsername","auth","canLoginWithEmail","canLoginWithUsername","whereConstraint","email","equals","or","push","username","existingUser","find","slug","depth","limit","pagination","where","docs","length","errors","message","t","path","hash","salt","sanitizedDoc","db","create","data"],"mappings":"AAIA,SAASA,eAAe,QAAQ,2BAA0B;AAC1D,SAASC,eAAe,QAAQ,2BAA0B;AAC1D,SAASC,wBAAwB,QAAQ,gCAA+B;AAUxE,OAAO,MAAMC,wBAAwB,OAAO,EAC1CC,UAAU,EACVC,GAAG,EACHC,QAAQ,EACRC,OAAO,EACPC,GAAG,EACE;IACL,MAAMC,oBAAoBL,YAAYM,MAAMD;IAE5C,MAAM,EAAEE,iBAAiB,EAAEC,oBAAoB,EAAE,GAAGX,gBAAgBQ;IAEpE,IAAII;IAEJ,IAAI,CAACD,sBAAsB;QACzBC,kBAAkB;YAChBC,OAAO;gBACLC,QAAQV,IAAIS,KAAK;YACnB;QACF;IACF,OAAO;QACLD,kBAAkB;YAChBG,IAAI,EAAE;QACR;QAEA,IAAIL,qBAAqBN,IAAIS,KAAK,EAAE;YAClCD,gBAAgBG,EAAE,EAAEC,KAAK;gBACvBH,OAAO;oBACLC,QAAQV,IAAIS,KAAK;gBACnB;YACF;QACF;QAEA,IAAIT,I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