@open-mercato/core 0.11.1-develop.8545.1.dd603570fd → 0.11.1-develop.8556.1.d944a8493f
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/.turbo/turbo-build.log +1 -1
- package/dist/modules/customer_accounts/api/admin/users/[id]/verify-email.js +10 -30
- package/dist/modules/customer_accounts/api/admin/users/[id]/verify-email.js.map +2 -2
- package/dist/modules/customer_accounts/api/email/verify.js +11 -10
- package/dist/modules/customer_accounts/api/email/verify.js.map +2 -2
- package/dist/modules/customer_accounts/api/magic-link/verify.js +9 -8
- package/dist/modules/customer_accounts/api/magic-link/verify.js.map +2 -2
- package/dist/modules/customer_accounts/api/password/reset-confirm.js +13 -16
- package/dist/modules/customer_accounts/api/password/reset-confirm.js.map +2 -2
- package/dist/modules/customer_accounts/api/signup.js +33 -19
- package/dist/modules/customer_accounts/api/signup.js.map +3 -3
- package/dist/modules/customer_accounts/data/validators.js +3 -2
- package/dist/modules/customer_accounts/data/validators.js.map +2 -2
- package/dist/modules/customer_accounts/lib/customerAuth.js +11 -10
- package/dist/modules/customer_accounts/lib/customerAuth.js.map +2 -2
- package/dist/modules/customer_accounts/lib/customerAuthServer.js +7 -7
- package/dist/modules/customer_accounts/lib/customerAuthServer.js.map +2 -2
- package/dist/modules/customer_accounts/lib/pendingSignup.js +16 -0
- package/dist/modules/customer_accounts/lib/pendingSignup.js.map +7 -0
- package/dist/modules/customer_accounts/lib/verifyCustomerEmail.js +50 -0
- package/dist/modules/customer_accounts/lib/verifyCustomerEmail.js.map +7 -0
- package/dist/modules/customer_accounts/services/customerInvitationService.js +15 -1
- package/dist/modules/customer_accounts/services/customerInvitationService.js.map +2 -2
- package/dist/modules/customer_accounts/services/customerTokenService.js +13 -13
- package/dist/modules/customer_accounts/services/customerTokenService.js.map +2 -2
- package/dist/modules/customer_accounts/services/customerUserService.js +1 -1
- package/dist/modules/customer_accounts/services/customerUserService.js.map +2 -2
- package/dist/modules/customer_accounts/subscribers/autoLinkCrm.js +44 -51
- package/dist/modules/customer_accounts/subscribers/autoLinkCrm.js.map +2 -2
- package/dist/modules/customer_accounts/subscribers/autoLinkCrmOnVerification.js +12 -0
- package/dist/modules/customer_accounts/subscribers/autoLinkCrmOnVerification.js.map +7 -0
- package/dist/modules/customer_accounts/subscribers/autoLinkCrmReverse.js +3 -1
- package/dist/modules/customer_accounts/subscribers/autoLinkCrmReverse.js.map +2 -2
- package/dist/modules/customer_accounts/workers/cleanupExpiredTokens.js +6 -0
- package/dist/modules/customer_accounts/workers/cleanupExpiredTokens.js.map +2 -2
- package/dist/modules/customers/commands/companies.js +8 -6
- package/dist/modules/customers/commands/companies.js.map +2 -2
- package/dist/modules/customers/commands/deals.js +24 -13
- package/dist/modules/customers/commands/deals.js.map +2 -2
- package/dist/modules/customers/commands/people.js +8 -6
- package/dist/modules/customers/commands/people.js.map +2 -2
- package/dist/modules/entities/lib/helpers.js +6 -2
- package/dist/modules/entities/lib/helpers.js.map +2 -2
- package/dist/modules/portal/frontend/[orgSlug]/portal/PasswordForm.js +127 -0
- package/dist/modules/portal/frontend/[orgSlug]/portal/PasswordForm.js.map +7 -0
- package/dist/modules/portal/frontend/[orgSlug]/portal/reset-password/page.js +10 -122
- package/dist/modules/portal/frontend/[orgSlug]/portal/reset-password/page.js.map +2 -2
- package/dist/modules/portal/frontend/[orgSlug]/portal/signup/page.js +2 -11
- package/dist/modules/portal/frontend/[orgSlug]/portal/signup/page.js.map +2 -2
- package/dist/modules/portal/frontend/[orgSlug]/portal/verify/page.js +3 -61
- package/dist/modules/portal/frontend/[orgSlug]/portal/verify/page.js.map +2 -2
- package/package.json +8 -8
- package/src/modules/customer_accounts/api/admin/users/[id]/verify-email.ts +11 -33
- package/src/modules/customer_accounts/api/email/verify.ts +15 -11
- package/src/modules/customer_accounts/api/magic-link/verify.ts +9 -9
- package/src/modules/customer_accounts/api/password/reset-confirm.ts +13 -18
- package/src/modules/customer_accounts/api/signup.ts +36 -24
- package/src/modules/customer_accounts/data/validators.ts +2 -1
- package/src/modules/customer_accounts/lib/customerAuth.ts +12 -10
- package/src/modules/customer_accounts/lib/customerAuthServer.ts +7 -7
- package/src/modules/customer_accounts/lib/pendingSignup.ts +12 -0
- package/src/modules/customer_accounts/lib/verifyCustomerEmail.ts +57 -0
- package/src/modules/customer_accounts/services/customerInvitationService.ts +16 -1
- package/src/modules/customer_accounts/services/customerTokenService.ts +13 -13
- package/src/modules/customer_accounts/services/customerUserService.ts +2 -2
- package/src/modules/customer_accounts/subscribers/autoLinkCrm.ts +46 -78
- package/src/modules/customer_accounts/subscribers/autoLinkCrmOnVerification.ts +9 -0
- package/src/modules/customer_accounts/subscribers/autoLinkCrmReverse.ts +3 -1
- package/src/modules/customer_accounts/workers/cleanupExpiredTokens.ts +7 -0
- package/src/modules/customers/commands/companies.ts +7 -5
- package/src/modules/customers/commands/deals.ts +22 -12
- package/src/modules/customers/commands/people.ts +7 -4
- package/src/modules/entities/lib/helpers.ts +8 -2
- package/src/modules/portal/frontend/[orgSlug]/portal/PasswordForm.tsx +182 -0
- package/src/modules/portal/frontend/[orgSlug]/portal/reset-password/page.tsx +9 -165
- package/src/modules/portal/frontend/[orgSlug]/portal/signup/page.tsx +2 -12
- package/src/modules/portal/frontend/[orgSlug]/portal/verify/page.tsx +3 -89
- package/src/modules/portal/i18n/de.json +2 -1
- package/src/modules/portal/i18n/en.json +2 -1
- package/src/modules/portal/i18n/es.json +2 -1
- package/src/modules/portal/i18n/ko.json +2 -1
- package/src/modules/portal/i18n/pl.json +2 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/entities/lib/helpers.ts"],
|
|
4
|
-
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/core'\nimport type { TenantDataEncryptionService } from '@open-mercato/shared/lib/encryption/tenantDataEncryptionService'\nimport { decryptCustomFieldValue, encryptCustomFieldValue, resolveTenantEncryptionService } from '@open-mercato/shared/lib/encryption/customFieldValues'\nimport {\n MAX_CUSTOM_FIELD_KEYS_PER_RECORD,\n TOO_MANY_CUSTOM_FIELDS_ERROR,\n} from '@open-mercato/shared/modules/entities/validation'\nimport { CustomFieldDef, CustomFieldValue } from '../data/entities'\nimport { loadScopedCustomFieldDefs } from './scoped-field-defs'\nimport { encryptCustomEntityDocument } from '@open-mercato/shared/lib/encryption/customEntityDoc'\nimport { isTenantDataEncryptionEnabled } from '@open-mercato/shared/lib/encryption/toggles'\n\n/** @internal */\nexport async function encryptCustomEntityRecordDocument(\n em: EntityManager,\n opts: { entityId: string; organizationId: string | null; tenantId: string | null; doc: Record<string, unknown>; encryptionService?: TenantDataEncryptionService | null },\n): Promise<Record<string, unknown>> {\n if (!isTenantDataEncryptionEnabled() || Object.keys(opts.doc).every((key) => key === 'id')) return opts.doc\n const definitions = await loadScopedCustomFieldDefs(em, opts)\n const fields = Array.from(definitions.values(), (definition) => ({\n key: definition.key,\n kind: definition.kind,\n encrypted: Boolean(definition.configJson?.encrypted),\n }))\n return encryptCustomEntityDocument(opts.doc, fields, opts.tenantId, resolveTenantEncryptionService(em, opts.encryptionService))\n}\n\ntype Primitive = string | number | boolean | null | undefined\ntype PrimitiveOrArray = Primitive | Primitive[]\n\nexport type SetRecordCustomFieldsOptions = {\n entityId: string\n recordId: string\n organizationId?: string | null\n tenantId?: string | null\n values: Record<string, PrimitiveOrArray>\n // When true (default), try to use field definitions to decide storage column\n preferDefs?: boolean\n // Optional: notify external systems (e.g., indexing) when values changed\n onChanged?: (payload: { entityId: string; recordId: string; organizationId: string | null; tenantId: string | null }) => Promise<void> | void\n // Optional: re-use an existing tenant encryption service instance\n encryptionService?: TenantDataEncryptionService | null\n // When true, additionally scope the reconciling delete/lookup by organizationId,\n // restoring the pre-#5970 organization pin. Default false relies on `recordId`\n // being unique across organizations for a given entityId \u2014 true for every\n // ORM-backed entity, where recordId is the record's own primary key. That\n // invariant does not hold for `custom_entities_storage` records written under\n // `ENTITIES_BACKCOMPAT_EAV_FOR_CUSTOM`: the table upserts on\n // `(entity_type, entity_id, organization_id)`, so the same id can be a live\n // record in two organizations of one tenant, and an organization-agnostic\n // delete could remove another organization's values (#6034 review). Callers\n // writing those records must pass pinOrganizationId: true.\n pinOrganizationId?: boolean\n}\n\nfunction columnFromKind(kind: string): keyof CustomFieldValue {\n switch (kind) {\n case 'text':\n case 'select':\n case 'currency':\n case 'dictionary':\n case 'phone':\n return 'valueText'\n case 'multiline':\n return 'valueMultiline'\n case 'integer':\n return 'valueInt'\n case 'float':\n return 'valueFloat'\n case 'boolean':\n return 'valueBool'\n default:\n return 'valueText'\n }\n}\n\nfunction columnFromJsValue(v: Primitive): keyof CustomFieldValue {\n if (v === null || v === undefined) return 'valueText'\n if (typeof v === 'boolean') return 'valueBool'\n if (typeof v === 'number') return Number.isInteger(v) ? 'valueInt' : 'valueFloat'\n return 'valueText'\n}\n\n// Clears all value columns to avoid leftovers on update\nfunction clearValueColumns(cf: CustomFieldValue) {\n cf.valueText = null\n cf.valueMultiline = null\n cf.valueInt = null\n cf.valueFloat = null\n cf.valueBool = null\n}\n\nfunction valueFromRow(row: CustomFieldValue): Primitive {\n if (row.valueMultiline != null) return row.valueMultiline\n if (row.valueText != null) return row.valueText\n if (row.valueInt != null) return row.valueInt\n if (row.valueFloat != null) return row.valueFloat\n if (row.valueBool != null) return row.valueBool\n return null\n}\n\n// Keeps the value the caller's own scope already holds when the echoed array contains it,\n// so a save that never touched the field does not swap in another organization's value.\nfunction pickSingleValue(candidates: Primitive[], currentValue: unknown): Primitive {\n if (currentValue != null) {\n const kept = candidates.find((candidate) => candidate != null && String(candidate) === String(currentValue))\n if (kept !== undefined) return kept\n }\n const present = candidates.filter((candidate) => candidate != null)\n return present.length ? present[present.length - 1] : null\n}\n\nexport async function setRecordCustomFields(\n em: EntityManager,\n opts: SetRecordCustomFieldsOptions,\n): Promise<void> {\n const { entityId, recordId, values } = opts\n const organizationId = opts.organizationId ?? null\n const tenantId = opts.tenantId ?? null\n const preferDefs = opts.preferDefs !== false\n\n let defsByKey: Map<string, CustomFieldDef> | undefined\n if (preferDefs) {\n defsByKey = await loadScopedCustomFieldDefs(em, { entityId, organizationId, tenantId })\n }\n\n const toPersist: CustomFieldValue[] = []\n let encryptionService: TenantDataEncryptionService | null | undefined\n const encryptionCache = new Map<string | null, string | null>()\n const getEncryptionService = () => {\n if (encryptionService !== undefined) return encryptionService\n encryptionService = resolveTenantEncryptionService(em as any, opts.encryptionService)\n return encryptionService\n }\n // A write owns every value row a reader in ITS OWN tenant scope could return for this\n // record: same logical key (entityId, recordId, fieldKey), any organization, and either\n // the caller's tenant or the instance-global NULL tenant \u2014 exactly what the Query Engine\n // matches. Organization is left out because the Query Engine's value join does not filter\n // it (engine.ts, the cf join and the EXISTS subquery), so a row from a scope the record\n // has left is indistinguishable from the live one (#5970). The query-index reader does\n // scope organization_id, but it never sees another organization's row for a record it is\n // indexing, so dropping the column here cannot widen what it returns.\n //\n // This relies on recordId being unique across organizations and tenants for a given\n // entityId \u2014 true of every ORM-backed caller, which passes the record's own primary key.\n // A caller that passed a per-organization natural key \u2014 or a recordId that is only unique\n // WITHIN an organization, as custom_entities_storage's EAV backcompat writes are \u2014 would\n // have one organization's write delete another's live rows. Those callers opt into\n // pinOrganizationId (see SetRecordCustomFieldsOptions) to restore the organization pin.\n //\n // Scope of the delete, precisely: another TENANT's own rows are never touched. Rows with a\n // NULL tenant are, deliberately \u2014 they are instance-global and answer every tenant's reads,\n // so leaving one behind would reproduce the very duplicate this reconciles. Spelled as an\n // explicit $or rather than `$in: [tenantId, null]` because SQL `IN (NULL)` never matches a\n // NULL row.\n const tenantScopeFilter = { $or: [{ tenantId }, { tenantId: null }] }\n const pinOrganizationId = opts.pinOrganizationId === true\n const reconcileScopeFilter = pinOrganizationId\n ? { organizationId, ...tenantScopeFilter }\n : tenantScopeFilter\n const keys = Object.keys(values)\n const presentKeyCount = keys.filter((key) => values[key] !== undefined).length\n if (preferDefs && presentKeyCount > MAX_CUSTOM_FIELD_KEYS_PER_RECORD) {\n throw new Error(TOO_MANY_CUSTOM_FIELDS_ERROR)\n }\n\n // Run the per-key delete+insert work inside ONE database transaction so a\n // multi-value replacement is atomic and isolated. The array branch deletes the\n // existing rows for a key and inserts the replacements; without an enclosing\n // transaction those can land in separate commit boundaries under MikroORM's\n // FlushMode.AUTO (a query elsewhere in the unit auto-flushes part of the work),\n // which intermittently left the field with the delete applied but the inserts\n // missing \u2014 the multi-select EDIT reverted to []. The single commit below makes\n // it all-or-nothing. We only open our own transaction when the caller has not\n // already started one (commands fork the request em and may run setCustomFields\n // outside their own withAtomicFlush tx); join an ambient transaction otherwise.\n const txEm = em as {\n begin?: () => Promise<void>\n commit?: () => Promise<void>\n rollback?: () => Promise<void>\n isInTransaction?: () => boolean\n }\n const txCapable =\n typeof txEm.begin === 'function' &&\n typeof txEm.commit === 'function' &&\n typeof txEm.rollback === 'function' &&\n typeof txEm.isInTransaction === 'function'\n const ownCustomFieldTransaction = txCapable && !txEm.isInTransaction!()\n if (ownCustomFieldTransaction) await txEm.begin!()\n try {\n for (const fieldKey of keys) {\n const raw = values[fieldKey]\n if (raw === undefined) continue\n\n const def = defsByKey?.get(fieldKey)\n const encrypted = Boolean(def?.configJson && (def as any).configJson?.encrypted)\n // A single-value definition never stores an array. One arrives when the detail read\n // returned the duplicate rows #5970 left behind as an array and a form echoed it back\n // unchanged; treating it as a multi-value replacement re-creates every duplicate under\n // the caller's organization (#6468). Collapse it to one value so the scalar branch\n // below reconciles the duplicates away.\n const collapseToSingle = Array.isArray(raw) && Boolean(def) && (def as any).configJson?.multi !== true\n const isArray = (Array.isArray(raw) && !collapseToSingle)\n || (raw === null && def?.configJson?.multi === true)\n // When array (multi-value): replace all existing rows for the key. Delete\n // first, then create replacements, all inside the transaction opened above.\n // Creating rows before a native delete can auto-flush and delete the new\n // values; mixing em.remove(stale) with new rows for the same EAV scope was\n // observed to commit an empty set under MikroORM v7. The explicit order keeps\n // the replacement atomic without letting old-row cleanup target new rows.\n if (isArray) {\n const arr = Array.isArray(raw) ? raw.filter((value) => value != null) : []\n // Reconciling delete (see tenantScopeFilter/reconcileScopeFilter): pinning\n // organizationId here left the rows written under the record's PREVIOUS\n // organization alive next to the replacements, and the Query Engine's value join\n // does not filter organization_id, so both generations answered the same lookup\n // (#5970) \u2014 unless the caller opted into pinOrganizationId because its recordId\n // is not unique across organizations.\n await em.nativeDelete(CustomFieldValue, { entityId, recordId, fieldKey, ...reconcileScopeFilter })\n for (const val of arr) {\n const col: keyof CustomFieldValue = encrypted ? 'valueText' : def ? columnFromKind(def.kind) : columnFromJsValue(val)\n const cf = em.create(CustomFieldValue, { entityId, recordId, organizationId, tenantId, fieldKey, createdAt: new Date() })\n clearValueColumns(cf)\n const stored = encrypted\n ? await encryptCustomFieldValue(val, tenantId, getEncryptionService(), encryptionCache, { entityId, fieldKey })\n : val\n switch (col) {\n case 'valueText': cf.valueText = stored == null ? null : String(stored); break\n case 'valueMultiline': cf.valueMultiline = stored == null ? null : String(stored); break\n case 'valueInt': cf.valueInt = stored == null ? null : Number(stored); break\n case 'valueFloat': cf.valueFloat = stored == null ? null : Number(stored); break\n case 'valueBool': cf.valueBool = stored == null ? null : Boolean(stored); break\n default: cf.valueText = stored == null ? null : String(stored); break\n }\n toPersist.push(cf)\n }\n continue\n }\n\n // Same reconciliation as the multi-value branch (see tenantScopeFilter): load every\n // reachable row for the logical key, reuse the one already in the caller's exact\n // scope and drop the rest, so a row left behind by a previous organization \u2014 and\n // same-scope duplicates from two writes that both missed the lookup \u2014 cannot\n // survive (#5970). Picking the survivor in JS rather than narrowing the query keeps\n // NULL organizations out of SQL three-valued logic, where an inequality predicate\n // would silently spare exactly the stale rows this is meant to remove.\n const existingRows = await em.find(CustomFieldValue, { entityId, recordId, fieldKey, ...reconcileScopeFilter })\n // A soft-deleted row is never the survivor: writing the new value onto it would leave\n // deleted_at set, hiding the field from loadCustomFieldValues while the live row it\n // replaced goes into staleIds. Tombstones still get deleted as stale \u2014 the Query\n // Engine's join does not filter deleted_at, so one left behind would answer reads.\n let cf = existingRows.find((row) => !row.deletedAt\n && (row.organizationId ?? null) === organizationId\n && (row.tenantId ?? null) === tenantId) ?? null\n const value: Primitive = collapseToSingle\n ? pickSingleValue(raw as Primitive[], cf ? await decryptCustomFieldValue(valueFromRow(cf), tenantId, encrypted ? getEncryptionService() : null, encryptionCache, { kind: def?.kind ?? null }) : undefined)\n : raw as Primitive\n const column: keyof CustomFieldValue = encrypted ? 'valueText' : def ? columnFromKind(def.kind) : columnFromJsValue(value)\n const storedValue = encrypted\n ? await encryptCustomFieldValue(value, tenantId, getEncryptionService(), encryptionCache, { entityId, fieldKey })\n : value\n const staleIds = existingRows.filter((row) => row !== cf).map((row) => row.id)\n if (staleIds.length) await em.nativeDelete(CustomFieldValue, { id: { $in: staleIds } })\n if (!cf) {\n cf = em.create(CustomFieldValue, { entityId, recordId, organizationId, tenantId, fieldKey, createdAt: new Date() })\n toPersist.push(cf)\n }\n clearValueColumns(cf)\n switch (column) {\n case 'valueText':\n cf.valueText = (storedValue as Primitive) == null ? null : String(storedValue as Primitive)\n break\n case 'valueMultiline':\n cf.valueMultiline = (storedValue as Primitive) == null ? null : String(storedValue as Primitive)\n break\n case 'valueInt':\n cf.valueInt = (storedValue as Primitive) == null ? null : Number(storedValue as Primitive)\n break\n case 'valueFloat':\n cf.valueFloat = (storedValue as Primitive) == null ? null : Number(storedValue as Primitive)\n break\n case 'valueBool':\n cf.valueBool = (storedValue as Primitive) == null ? null : Boolean(storedValue as Primitive)\n break\n default:\n cf.valueText = (storedValue as Primitive) == null ? null : String(storedValue as Primitive)\n break\n }\n }\n\n if (toPersist.length) em.persist(toPersist)\n await em.flush()\n if (ownCustomFieldTransaction) await txEm.commit!()\n } catch (err) {\n if (ownCustomFieldTransaction) {\n try { await txEm.rollback!() } catch { /* surface the original error, not a rollback failure */ }\n }\n throw err\n }\n // Emit hook for indexing if requested (outside CRUD flows). Runs AFTER the\n // transaction commits so consumers observe the persisted rows.\n try {\n if (typeof opts.onChanged === 'function') {\n await opts.onChanged({ entityId, recordId, organizationId, tenantId })\n }\n } catch {\n // Non-blocking\n }\n}\n"],
|
|
5
|
-
"mappings": "AAEA,SAAS,yBAAyB,yBAAyB,sCAAsC;AACjG;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAyB,wBAAwB;AACjD,SAAS,iCAAiC;AAC1C,SAAS,mCAAmC;AAC5C,SAAS,qCAAqC;AAG9C,eAAsB,kCACpB,IACA,MACkC;AAClC,MAAI,CAAC,8BAA8B,KAAK,OAAO,KAAK,KAAK,GAAG,EAAE,MAAM,CAAC,QAAQ,QAAQ,IAAI,EAAG,QAAO,KAAK;AACxG,QAAM,cAAc,MAAM,0BAA0B,IAAI,IAAI;AAC5D,QAAM,SAAS,MAAM,KAAK,YAAY,OAAO,GAAG,CAAC,gBAAgB;AAAA,IAC/D,KAAK,WAAW;AAAA,IAChB,MAAM,WAAW;AAAA,IACjB,WAAW,QAAQ,WAAW,YAAY,SAAS;AAAA,EACrD,EAAE;AACF,SAAO,4BAA4B,KAAK,KAAK,QAAQ,KAAK,UAAU,+BAA+B,IAAI,KAAK,iBAAiB,CAAC;AAChI;AA8BA,SAAS,eAAe,MAAsC;AAC5D,UAAQ,MAAM;AAAA,IACZ,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,kBAAkB,GAAsC;AAC/D,MAAI,MAAM,QAAQ,MAAM,OAAW,QAAO;AAC1C,MAAI,OAAO,MAAM,UAAW,QAAO;AACnC,MAAI,OAAO,MAAM,SAAU,QAAO,OAAO,UAAU,CAAC,IAAI,aAAa;AACr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AAkB,EAAE,UAAU,UAAU,gBAAgB,UAAU,UAAU,WAAW,oBAAI,KAAK,EAAE,CAAC;AACxH,4BAAkBA,GAAE;AACpB,gBAAM,SAAS,YACX,MAAM,wBAAwB,KAAK,UAAU,qBAAqB,GAAG,iBAAiB,EAAE,UAAU,SAAS,CAAC,IAC5G;AACJ,kBAAQ,KAAK;AAAA,YACX,KAAK;AAAa,cAAAA,IAAG,YAAY,UAAU,OAAO,OAAO,OAAO,MAAM;AAAG;AAAA,YACzE,KAAK;AAAkB,cAAAA,IAAG,iBAAiB,UAAU,OAAO,OAAO,OAAO,MAAM;AAAG;AAAA,YACnF,KAAK;AAAY,cAAAA,IAAG,WAAW,UAAU,OAAO,OAAO,OAAO,MAAM;AAAG;AAAA,YACvE,KAAK;AAAc,cAAAA,IAAG,aAAa,UAAU,OAAO,OAAO,OAAO,MAAM;AAAG;AAAA,YAC3E,KAAK;AAAa,cAAAA,IAAG,YAAY,UAAU,OAAO,OAAO,QAAQ,MAAM;AAAG;AAAA,YAC1E;AAAS,cAAAA,IAAG,YAAY,UAAU,OAAO,OAAO,OAAO,MAAM;AAAG;AAAA,UAClE;AACA,oBAAU,KAAKA,GAAE;AAAA,QACnB;AACA;AAAA,MACF;AASA,YAAM,eAAe,MAAM,GAAG,KAAK,kBAAkB,EAAE,UAAU,UAAU,UAAU,GAAG,qBAAqB,CAAC;AAK9G,UAAI,KAAK,aAAa,KAAK,CAAC,QAAQ,CAAC,IAAI,cACnC,IAAI,kBAAkB,UAAU,mBAChC,IAAI,YAAY,UAAU,QAAQ,KAAK;AAC7C,YAAM,
|
|
4
|
+
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/core'\nimport type { TenantDataEncryptionService } from '@open-mercato/shared/lib/encryption/tenantDataEncryptionService'\nimport { decryptCustomFieldValue, encryptCustomFieldValue, resolveTenantEncryptionService } from '@open-mercato/shared/lib/encryption/customFieldValues'\nimport {\n MAX_CUSTOM_FIELD_KEYS_PER_RECORD,\n TOO_MANY_CUSTOM_FIELDS_ERROR,\n} from '@open-mercato/shared/modules/entities/validation'\nimport { CustomFieldDef, CustomFieldValue } from '../data/entities'\nimport { loadScopedCustomFieldDefs } from './scoped-field-defs'\nimport { encryptCustomEntityDocument } from '@open-mercato/shared/lib/encryption/customEntityDoc'\nimport { isTenantDataEncryptionEnabled } from '@open-mercato/shared/lib/encryption/toggles'\n\n/** @internal */\nexport async function encryptCustomEntityRecordDocument(\n em: EntityManager,\n opts: { entityId: string; organizationId: string | null; tenantId: string | null; doc: Record<string, unknown>; encryptionService?: TenantDataEncryptionService | null },\n): Promise<Record<string, unknown>> {\n if (!isTenantDataEncryptionEnabled() || Object.keys(opts.doc).every((key) => key === 'id')) return opts.doc\n const definitions = await loadScopedCustomFieldDefs(em, opts)\n const fields = Array.from(definitions.values(), (definition) => ({\n key: definition.key,\n kind: definition.kind,\n encrypted: Boolean(definition.configJson?.encrypted),\n }))\n return encryptCustomEntityDocument(opts.doc, fields, opts.tenantId, resolveTenantEncryptionService(em, opts.encryptionService))\n}\n\ntype Primitive = string | number | boolean | null | undefined\ntype PrimitiveOrArray = Primitive | Primitive[]\n\nexport type SetRecordCustomFieldsOptions = {\n entityId: string\n recordId: string\n organizationId?: string | null\n tenantId?: string | null\n values: Record<string, PrimitiveOrArray>\n // When true (default), try to use field definitions to decide storage column\n preferDefs?: boolean\n // Optional: notify external systems (e.g., indexing) when values changed\n onChanged?: (payload: { entityId: string; recordId: string; organizationId: string | null; tenantId: string | null }) => Promise<void> | void\n // Optional: re-use an existing tenant encryption service instance\n encryptionService?: TenantDataEncryptionService | null\n // When true, additionally scope the reconciling delete/lookup by organizationId,\n // restoring the pre-#5970 organization pin. Default false relies on `recordId`\n // being unique across organizations for a given entityId \u2014 true for every\n // ORM-backed entity, where recordId is the record's own primary key. That\n // invariant does not hold for `custom_entities_storage` records written under\n // `ENTITIES_BACKCOMPAT_EAV_FOR_CUSTOM`: the table upserts on\n // `(entity_type, entity_id, organization_id)`, so the same id can be a live\n // record in two organizations of one tenant, and an organization-agnostic\n // delete could remove another organization's values (#6034 review). Callers\n // writing those records must pass pinOrganizationId: true.\n pinOrganizationId?: boolean\n}\n\nfunction columnFromKind(kind: string): keyof CustomFieldValue {\n switch (kind) {\n case 'text':\n case 'select':\n case 'currency':\n case 'dictionary':\n case 'phone':\n return 'valueText'\n case 'multiline':\n return 'valueMultiline'\n case 'integer':\n return 'valueInt'\n case 'float':\n return 'valueFloat'\n case 'boolean':\n return 'valueBool'\n default:\n return 'valueText'\n }\n}\n\nfunction columnFromJsValue(v: Primitive): keyof CustomFieldValue {\n if (v === null || v === undefined) return 'valueText'\n if (typeof v === 'boolean') return 'valueBool'\n if (typeof v === 'number') return Number.isInteger(v) ? 'valueInt' : 'valueFloat'\n return 'valueText'\n}\n\n// Clears all value columns to avoid leftovers on update\nfunction clearValueColumns(cf: CustomFieldValue) {\n cf.valueText = null\n cf.valueMultiline = null\n cf.valueInt = null\n cf.valueFloat = null\n cf.valueBool = null\n}\n\nfunction valueFromRow(row: CustomFieldValue): Primitive {\n if (row.valueMultiline != null) return row.valueMultiline\n if (row.valueText != null) return row.valueText\n if (row.valueInt != null) return row.valueInt\n if (row.valueFloat != null) return row.valueFloat\n if (row.valueBool != null) return row.valueBool\n return null\n}\n\n// Keeps the value the caller's own scope already holds when the echoed array contains it,\n// so a save that never touched the field does not swap in another organization's value.\nfunction pickSingleValue(candidates: Primitive[], currentValue: unknown): Primitive {\n if (currentValue != null) {\n const kept = candidates.find((candidate) => candidate != null && String(candidate) === String(currentValue))\n if (kept !== undefined) return kept\n }\n const present = candidates.filter((candidate) => candidate != null)\n return present.length ? present[present.length - 1] : null\n}\n\nexport async function setRecordCustomFields(\n em: EntityManager,\n opts: SetRecordCustomFieldsOptions,\n): Promise<void> {\n const { entityId, recordId, values } = opts\n const organizationId = opts.organizationId ?? null\n const tenantId = opts.tenantId ?? null\n const preferDefs = opts.preferDefs !== false\n\n let defsByKey: Map<string, CustomFieldDef> | undefined\n if (preferDefs) {\n defsByKey = await loadScopedCustomFieldDefs(em, { entityId, organizationId, tenantId })\n }\n\n const toPersist: CustomFieldValue[] = []\n let encryptionService: TenantDataEncryptionService | null | undefined\n const encryptionCache = new Map<string | null, string | null>()\n const getEncryptionService = () => {\n if (encryptionService !== undefined) return encryptionService\n encryptionService = resolveTenantEncryptionService(em as any, opts.encryptionService)\n return encryptionService\n }\n // A write owns every value row a reader in ITS OWN tenant scope could return for this\n // record: same logical key (entityId, recordId, fieldKey), any organization, and either\n // the caller's tenant or the instance-global NULL tenant \u2014 exactly what the Query Engine\n // matches. Organization is left out because the Query Engine's value join does not filter\n // it (engine.ts, the cf join and the EXISTS subquery), so a row from a scope the record\n // has left is indistinguishable from the live one (#5970). The query-index reader does\n // scope organization_id, but it never sees another organization's row for a record it is\n // indexing, so dropping the column here cannot widen what it returns.\n //\n // This relies on recordId being unique across organizations and tenants for a given\n // entityId \u2014 true of every ORM-backed caller, which passes the record's own primary key.\n // A caller that passed a per-organization natural key \u2014 or a recordId that is only unique\n // WITHIN an organization, as custom_entities_storage's EAV backcompat writes are \u2014 would\n // have one organization's write delete another's live rows. Those callers opt into\n // pinOrganizationId (see SetRecordCustomFieldsOptions) to restore the organization pin.\n //\n // Scope of the delete, precisely: another TENANT's own rows are never touched. Rows with a\n // NULL tenant are, deliberately \u2014 they are instance-global and answer every tenant's reads,\n // so leaving one behind would reproduce the very duplicate this reconciles. Spelled as an\n // explicit $or rather than `$in: [tenantId, null]` because SQL `IN (NULL)` never matches a\n // NULL row.\n const tenantScopeFilter = { $or: [{ tenantId }, { tenantId: null }] }\n const pinOrganizationId = opts.pinOrganizationId === true\n const reconcileScopeFilter = pinOrganizationId\n ? { organizationId, ...tenantScopeFilter }\n : tenantScopeFilter\n const keys = Object.keys(values)\n const presentKeyCount = keys.filter((key) => values[key] !== undefined).length\n if (preferDefs && presentKeyCount > MAX_CUSTOM_FIELD_KEYS_PER_RECORD) {\n throw new Error(TOO_MANY_CUSTOM_FIELDS_ERROR)\n }\n\n // Run the per-key delete+insert work inside ONE database transaction so a\n // multi-value replacement is atomic and isolated. The array branch deletes the\n // existing rows for a key and inserts the replacements; without an enclosing\n // transaction those can land in separate commit boundaries under MikroORM's\n // FlushMode.AUTO (a query elsewhere in the unit auto-flushes part of the work),\n // which intermittently left the field with the delete applied but the inserts\n // missing \u2014 the multi-select EDIT reverted to []. The single commit below makes\n // it all-or-nothing. We only open our own transaction when the caller has not\n // already started one (commands fork the request em and may run setCustomFields\n // outside their own withAtomicFlush tx); join an ambient transaction otherwise.\n const txEm = em as {\n begin?: () => Promise<void>\n commit?: () => Promise<void>\n rollback?: () => Promise<void>\n isInTransaction?: () => boolean\n }\n const txCapable =\n typeof txEm.begin === 'function' &&\n typeof txEm.commit === 'function' &&\n typeof txEm.rollback === 'function' &&\n typeof txEm.isInTransaction === 'function'\n const ownCustomFieldTransaction = txCapable && !txEm.isInTransaction!()\n if (ownCustomFieldTransaction) await txEm.begin!()\n try {\n for (const fieldKey of keys) {\n const raw = values[fieldKey]\n if (raw === undefined) continue\n\n const def = defsByKey?.get(fieldKey)\n const encrypted = Boolean(def?.configJson && (def as any).configJson?.encrypted)\n // A single-value definition never stores an array. One arrives when the detail read\n // returned the duplicate rows #5970 left behind as an array and a form echoed it back\n // unchanged; treating it as a multi-value replacement re-creates every duplicate under\n // the caller's organization (#6468). Collapse it to one value so the scalar branch\n // below reconciles the duplicates away.\n const collapseToSingle = Array.isArray(raw) && Boolean(def) && (def as any).configJson?.multi !== true\n const isArray = (Array.isArray(raw) && !collapseToSingle)\n || (raw === null && def?.configJson?.multi === true)\n // When array (multi-value): replace all existing rows for the key. Delete\n // first, then create replacements, all inside the transaction opened above.\n // Creating rows before a native delete can auto-flush and delete the new\n // values; mixing em.remove(stale) with new rows for the same EAV scope was\n // observed to commit an empty set under MikroORM v7. The explicit order keeps\n // the replacement atomic without letting old-row cleanup target new rows.\n if (isArray) {\n const arr = Array.isArray(raw) ? raw.filter((value) => value != null) : []\n // Reconciling delete (see tenantScopeFilter/reconcileScopeFilter): pinning\n // organizationId here left the rows written under the record's PREVIOUS\n // organization alive next to the replacements, and the Query Engine's value join\n // does not filter organization_id, so both generations answered the same lookup\n // (#5970) \u2014 unless the caller opted into pinOrganizationId because its recordId\n // is not unique across organizations.\n await em.nativeDelete(CustomFieldValue, { entityId, recordId, fieldKey, ...reconcileScopeFilter })\n for (const val of arr) {\n const col: keyof CustomFieldValue = encrypted ? 'valueText' : def ? columnFromKind(def.kind) : columnFromJsValue(val)\n const cf = em.create(CustomFieldValue, { entityId, recordId, organizationId, tenantId, fieldKey, createdAt: new Date() })\n clearValueColumns(cf)\n const stored = encrypted\n ? await encryptCustomFieldValue(val, tenantId, getEncryptionService(), encryptionCache, { entityId, fieldKey })\n : val\n switch (col) {\n case 'valueText': cf.valueText = stored == null ? null : String(stored); break\n case 'valueMultiline': cf.valueMultiline = stored == null ? null : String(stored); break\n case 'valueInt': cf.valueInt = stored == null ? null : Number(stored); break\n case 'valueFloat': cf.valueFloat = stored == null ? null : Number(stored); break\n case 'valueBool': cf.valueBool = stored == null ? null : Boolean(stored); break\n default: cf.valueText = stored == null ? null : String(stored); break\n }\n toPersist.push(cf)\n }\n continue\n }\n\n // Same reconciliation as the multi-value branch (see tenantScopeFilter): load every\n // reachable row for the logical key, reuse the one already in the caller's exact\n // scope and drop the rest, so a row left behind by a previous organization \u2014 and\n // same-scope duplicates from two writes that both missed the lookup \u2014 cannot\n // survive (#5970). Picking the survivor in JS rather than narrowing the query keeps\n // NULL organizations out of SQL three-valued logic, where an inequality predicate\n // would silently spare exactly the stale rows this is meant to remove.\n const existingRows = await em.find(CustomFieldValue, { entityId, recordId, fieldKey, ...reconcileScopeFilter })\n // A soft-deleted row is never the survivor: writing the new value onto it would leave\n // deleted_at set, hiding the field from loadCustomFieldValues while the live row it\n // replaced goes into staleIds. Tombstones still get deleted as stale \u2014 the Query\n // Engine's join does not filter deleted_at, so one left behind would answer reads.\n let cf = existingRows.find((row) => !row.deletedAt\n && (row.organizationId ?? null) === organizationId\n && (row.tenantId ?? null) === tenantId) ?? null\n const currentValue = collapseToSingle && raw.some((candidate) => candidate != null) && cf\n ? await decryptCustomFieldValue(valueFromRow(cf), tenantId, encrypted ? getEncryptionService() : null, encryptionCache, {\n kind: def?.kind ?? null,\n writeContext: encrypted ? { entityId, fieldKey } : undefined,\n })\n : undefined\n const value: Primitive = collapseToSingle\n ? pickSingleValue(raw as Primitive[], currentValue)\n : raw as Primitive\n const column: keyof CustomFieldValue = encrypted ? 'valueText' : def ? columnFromKind(def.kind) : columnFromJsValue(value)\n const storedValue = encrypted && value != null\n ? await encryptCustomFieldValue(value, tenantId, getEncryptionService(), encryptionCache, { entityId, fieldKey })\n : value\n const staleIds = existingRows.filter((row) => row !== cf).map((row) => row.id)\n if (staleIds.length) await em.nativeDelete(CustomFieldValue, { id: { $in: staleIds } })\n if (!cf) {\n cf = em.create(CustomFieldValue, { entityId, recordId, organizationId, tenantId, fieldKey, createdAt: new Date() })\n toPersist.push(cf)\n }\n clearValueColumns(cf)\n switch (column) {\n case 'valueText':\n cf.valueText = (storedValue as Primitive) == null ? null : String(storedValue as Primitive)\n break\n case 'valueMultiline':\n cf.valueMultiline = (storedValue as Primitive) == null ? null : String(storedValue as Primitive)\n break\n case 'valueInt':\n cf.valueInt = (storedValue as Primitive) == null ? null : Number(storedValue as Primitive)\n break\n case 'valueFloat':\n cf.valueFloat = (storedValue as Primitive) == null ? null : Number(storedValue as Primitive)\n break\n case 'valueBool':\n cf.valueBool = (storedValue as Primitive) == null ? null : Boolean(storedValue as Primitive)\n break\n default:\n cf.valueText = (storedValue as Primitive) == null ? null : String(storedValue as Primitive)\n break\n }\n }\n\n if (toPersist.length) em.persist(toPersist)\n await em.flush()\n if (ownCustomFieldTransaction) await txEm.commit!()\n } catch (err) {\n if (ownCustomFieldTransaction) {\n try { await txEm.rollback!() } catch { /* surface the original error, not a rollback failure */ }\n }\n throw err\n }\n // Emit hook for indexing if requested (outside CRUD flows). Runs AFTER the\n // transaction commits so consumers observe the persisted rows.\n try {\n if (typeof opts.onChanged === 'function') {\n await opts.onChanged({ entityId, recordId, organizationId, tenantId })\n }\n } catch {\n // Non-blocking\n }\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,yBAAyB,yBAAyB,sCAAsC;AACjG;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAyB,wBAAwB;AACjD,SAAS,iCAAiC;AAC1C,SAAS,mCAAmC;AAC5C,SAAS,qCAAqC;AAG9C,eAAsB,kCACpB,IACA,MACkC;AAClC,MAAI,CAAC,8BAA8B,KAAK,OAAO,KAAK,KAAK,GAAG,EAAE,MAAM,CAAC,QAAQ,QAAQ,IAAI,EAAG,QAAO,KAAK;AACxG,QAAM,cAAc,MAAM,0BAA0B,IAAI,IAAI;AAC5D,QAAM,SAAS,MAAM,KAAK,YAAY,OAAO,GAAG,CAAC,gBAAgB;AAAA,IAC/D,KAAK,WAAW;AAAA,IAChB,MAAM,WAAW;AAAA,IACjB,WAAW,QAAQ,WAAW,YAAY,SAAS;AAAA,EACrD,EAAE;AACF,SAAO,4BAA4B,KAAK,KAAK,QAAQ,KAAK,UAAU,+BAA+B,IAAI,KAAK,iBAAiB,CAAC;AAChI;AA8BA,SAAS,eAAe,MAAsC;AAC5D,UAAQ,MAAM;AAAA,IACZ,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,kBAAkB,GAAsC;AAC/D,MAAI,MAAM,QAAQ,MAAM,OAAW,QAAO;AAC1C,MAAI,OAAO,MAAM,UAAW,QAAO;AACnC,MAAI,OAAO,MAAM,SAAU,QAAO,OAAO,UAAU,CAAC,IAAI,aAA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,QAAI,2BAA2B;AAC7B,UAAI;AAAE,cAAM,KAAK,SAAU;AAAA,MAAE,QAAQ;AAAA,MAA2D;AAAA,IAClG;AACA,UAAM;AAAA,EACR;AAGA,MAAI;AACF,QAAI,OAAO,KAAK,cAAc,YAAY;AACxC,YAAM,KAAK,UAAU,EAAE,UAAU,UAAU,gBAAgB,SAAS,CAAC;AAAA,IACvE;AAAA,EACF,QAAQ;AAAA,EAER;AACF;",
|
|
6
6
|
"names": ["value", "cf"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useState, useEffect } from "react";
|
|
4
|
+
import { useSearchParams } from "next/navigation";
|
|
5
|
+
import Link from "next/link";
|
|
6
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
7
|
+
import { PasswordInput } from "@open-mercato/ui/primitives/password-input";
|
|
8
|
+
import { Label } from "@open-mercato/ui/primitives/label";
|
|
9
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
10
|
+
import { Alert, AlertDescription } from "@open-mercato/ui/primitives/alert";
|
|
11
|
+
import { EmptyState } from "@open-mercato/ui/primitives/empty-state";
|
|
12
|
+
import { SearchX } from "lucide-react";
|
|
13
|
+
import { Spinner } from "@open-mercato/ui/primitives/spinner";
|
|
14
|
+
import { apiCall } from "@open-mercato/ui/backend/utils/apiCall";
|
|
15
|
+
import { usePortalContext } from "@open-mercato/ui/portal/PortalContext";
|
|
16
|
+
function PortalPasswordForm({ params, verify = false, beforeForm, afterForm }) {
|
|
17
|
+
const t = useT();
|
|
18
|
+
const orgSlug = params.orgSlug;
|
|
19
|
+
const { tenant } = usePortalContext();
|
|
20
|
+
const searchParams = useSearchParams();
|
|
21
|
+
const [password, setPassword] = useState("");
|
|
22
|
+
const [confirmPassword, setConfirmPassword] = useState("");
|
|
23
|
+
const [error, setError] = useState(null);
|
|
24
|
+
const [success, setSuccess] = useState(false);
|
|
25
|
+
const [submitting, setSubmitting] = useState(false);
|
|
26
|
+
const token = searchParams.get("token");
|
|
27
|
+
const noTokenMessage = verify ? t("portal.verify.error.invalidToken", "Verification token is missing.") : t("portal.resetPassword.error.noToken", "Invalid or missing reset token.");
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!token) setError(noTokenMessage);
|
|
30
|
+
}, [token, noTokenMessage]);
|
|
31
|
+
const handleSubmit = useCallback(
|
|
32
|
+
async (event) => {
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
setError(null);
|
|
35
|
+
if (!token) {
|
|
36
|
+
setError(noTokenMessage);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (password !== confirmPassword) {
|
|
40
|
+
setError(t("portal.resetPassword.error.passwordMismatch", "Passwords do not match."));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (password.length < 8) {
|
|
44
|
+
setError(t("portal.resetPassword.error.passwordTooShort", "Password must be at least 8 characters long."));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
setSubmitting(true);
|
|
48
|
+
try {
|
|
49
|
+
const endpoint = verify ? "/api/customer_accounts/email/verify" : "/api/customer_accounts/password/reset-confirm";
|
|
50
|
+
const result = await apiCall(endpoint, {
|
|
51
|
+
method: "POST",
|
|
52
|
+
headers: { "Content-Type": "application/json" },
|
|
53
|
+
body: JSON.stringify({ token, password })
|
|
54
|
+
});
|
|
55
|
+
if (result.ok && result.result?.ok) {
|
|
56
|
+
setSuccess(true);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (verify) {
|
|
60
|
+
setError(t("portal.verify.error.generic", "Email verification failed. Please try again."));
|
|
61
|
+
} else if (result.status === 400) {
|
|
62
|
+
setError(t("portal.resetPassword.error.invalidToken", "Invalid or expired reset token."));
|
|
63
|
+
} else {
|
|
64
|
+
setError(result.result?.error || t("portal.resetPassword.error.generic", "Password reset failed. Please try again."));
|
|
65
|
+
}
|
|
66
|
+
} catch {
|
|
67
|
+
setError(verify ? t("portal.verify.error.generic", "Email verification failed. Please try again.") : t("portal.resetPassword.error.generic", "Password reset failed. Please try again."));
|
|
68
|
+
} finally {
|
|
69
|
+
setSubmitting(false);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
[token, password, confirmPassword, t, verify, noTokenMessage]
|
|
73
|
+
);
|
|
74
|
+
if (tenant.loading) {
|
|
75
|
+
return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-20", children: /* @__PURE__ */ jsx(Spinner, {}) });
|
|
76
|
+
}
|
|
77
|
+
if (tenant.error) {
|
|
78
|
+
return /* @__PURE__ */ jsx("div", { className: "mx-auto w-full max-w-md py-12", children: /* @__PURE__ */ jsx(
|
|
79
|
+
EmptyState,
|
|
80
|
+
{
|
|
81
|
+
variant: "subtle",
|
|
82
|
+
size: "lg",
|
|
83
|
+
icon: /* @__PURE__ */ jsx(SearchX, { className: "h-6 w-6", "aria-hidden": true }),
|
|
84
|
+
title: t("portal.org.invalid", "Organization not found.")
|
|
85
|
+
}
|
|
86
|
+
) });
|
|
87
|
+
}
|
|
88
|
+
if (success) {
|
|
89
|
+
return /* @__PURE__ */ jsxs("div", { className: "mx-auto w-full max-w-sm", children: [
|
|
90
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-8 text-center", children: [
|
|
91
|
+
/* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold tracking-tight", children: verify ? t("portal.verify.success.title", "Email verified") : t("portal.resetPassword.success.title", "Password Reset Complete") }),
|
|
92
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1.5 text-sm text-muted-foreground", children: verify ? t("portal.verify.success.description", "Your email has been verified. You can now sign in to the portal.") : t("portal.resetPassword.success.description", "Your password has been successfully reset.") })
|
|
93
|
+
] }),
|
|
94
|
+
/* @__PURE__ */ jsx(Alert, { children: /* @__PURE__ */ jsx(AlertDescription, { children: t("portal.resetPassword.success.message", "You can now sign in with your new password.") }) }),
|
|
95
|
+
/* @__PURE__ */ jsx("div", { className: "mt-6 text-center", children: /* @__PURE__ */ jsx(Link, { href: `/${orgSlug}/portal/login`, className: "font-medium text-foreground underline underline-offset-4 hover:opacity-80", children: t("portal.resetPassword.success.loginLink", "Go to Sign In") }) })
|
|
96
|
+
] });
|
|
97
|
+
}
|
|
98
|
+
return /* @__PURE__ */ jsxs("div", { className: "mx-auto w-full max-w-sm", children: [
|
|
99
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-8 text-center", children: [
|
|
100
|
+
/* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold tracking-tight", children: verify ? t("portal.verify.title", "Verify email") : t("portal.resetPassword.title", "Reset Password") }),
|
|
101
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1.5 text-sm text-muted-foreground", children: t("portal.resetPassword.description", "Enter your new password below.") })
|
|
102
|
+
] }),
|
|
103
|
+
beforeForm,
|
|
104
|
+
/* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "flex flex-col gap-4", children: [
|
|
105
|
+
error ? /* @__PURE__ */ jsx(Alert, { status: "error", children: /* @__PURE__ */ jsx(AlertDescription, { children: error }) }) : null,
|
|
106
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
107
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "reset-password", className: "text-overline font-semibold uppercase tracking-wider text-muted-foreground/70", children: t("portal.resetPassword.password", "New Password") }),
|
|
108
|
+
/* @__PURE__ */ jsx(PasswordInput, { id: "reset-password", autoComplete: "new-password", required: true, placeholder: t("portal.resetPassword.password.placeholder", "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"), value: password, onChange: (e) => setPassword(e.target.value), disabled: submitting || !token, className: "rounded-lg" })
|
|
109
|
+
] }),
|
|
110
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
111
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "confirm-password", className: "text-overline font-semibold uppercase tracking-wider text-muted-foreground/70", children: t("portal.resetPassword.confirmPassword", "Confirm New Password") }),
|
|
112
|
+
/* @__PURE__ */ jsx(PasswordInput, { id: "confirm-password", autoComplete: "new-password", required: true, placeholder: t("portal.resetPassword.confirmPassword.placeholder", "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"), value: confirmPassword, onChange: (e) => setConfirmPassword(e.target.value), disabled: submitting || !token, className: "rounded-lg" })
|
|
113
|
+
] }),
|
|
114
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", disabled: submitting || !token, className: "mt-1 w-full rounded-lg", children: verify ? t("portal.verify.submit", "Verify email and set password") : submitting ? t("portal.resetPassword.submitting", "Resetting password...") : t("portal.resetPassword.submit", "Reset Password") }),
|
|
115
|
+
/* @__PURE__ */ jsxs("p", { className: "text-center text-sm text-muted-foreground", children: [
|
|
116
|
+
verify ? null : t("portal.resetPassword.backToLogin", "Remember your password?"),
|
|
117
|
+
" ",
|
|
118
|
+
/* @__PURE__ */ jsx(Link, { href: `/${orgSlug}/portal/login`, className: "font-medium text-foreground underline underline-offset-4 hover:opacity-80", children: t("portal.resetPassword.loginLink", "Sign in") })
|
|
119
|
+
] })
|
|
120
|
+
] }),
|
|
121
|
+
afterForm
|
|
122
|
+
] });
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
PortalPasswordForm
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=PasswordForm.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/modules/portal/frontend/%5BorgSlug%5D/portal/PasswordForm.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport { useCallback, useState, useEffect, type ReactNode } from 'react'\nimport { useSearchParams } from 'next/navigation'\nimport Link from 'next/link'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { PasswordInput } from '@open-mercato/ui/primitives/password-input'\nimport { Label } from '@open-mercato/ui/primitives/label'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Alert, AlertDescription } from '@open-mercato/ui/primitives/alert'\nimport { EmptyState } from '@open-mercato/ui/primitives/empty-state'\nimport { SearchX } from 'lucide-react'\nimport { Spinner } from '@open-mercato/ui/primitives/spinner'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { usePortalContext } from '@open-mercato/ui/portal/PortalContext'\n\ntype Props = {\n params: { orgSlug: string }\n verify?: boolean\n beforeForm?: ReactNode\n afterForm?: ReactNode\n}\n\nexport function PortalPasswordForm({ params, verify = false, beforeForm, afterForm }: Props) {\n const t = useT()\n const orgSlug = params.orgSlug\n const { tenant } = usePortalContext()\n const searchParams = useSearchParams()\n\n const [password, setPassword] = useState('')\n const [confirmPassword, setConfirmPassword] = useState('')\n const [error, setError] = useState<string | null>(null)\n const [success, setSuccess] = useState(false)\n const [submitting, setSubmitting] = useState(false)\n const token = searchParams.get('token')\n const noTokenMessage = verify\n ? t('portal.verify.error.invalidToken', 'Verification token is missing.')\n : t('portal.resetPassword.error.noToken', 'Invalid or missing reset token.')\n\n useEffect(() => {\n if (!token) setError(noTokenMessage)\n }, [token, noTokenMessage])\n\n const handleSubmit = useCallback(\n async (event: React.FormEvent) => {\n event.preventDefault()\n setError(null)\n\n if (!token) {\n setError(noTokenMessage)\n return\n }\n\n if (password !== confirmPassword) {\n setError(t('portal.resetPassword.error.passwordMismatch', 'Passwords do not match.'))\n return\n }\n\n if (password.length < 8) {\n setError(t('portal.resetPassword.error.passwordTooShort', 'Password must be at least 8 characters long.'))\n return\n }\n\n setSubmitting(true)\n try {\n const endpoint = verify ? '/api/customer_accounts/email/verify' : '/api/customer_accounts/password/reset-confirm'\n const result = await apiCall<{ ok: boolean; error?: string }>(endpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ token, password }),\n })\n\n if (result.ok && result.result?.ok) {\n setSuccess(true)\n return\n }\n\n if (verify) {\n setError(t('portal.verify.error.generic', 'Email verification failed. Please try again.'))\n } else if (result.status === 400) {\n setError(t('portal.resetPassword.error.invalidToken', 'Invalid or expired reset token.'))\n } else {\n setError(result.result?.error || t('portal.resetPassword.error.generic', 'Password reset failed. Please try again.'))\n }\n } catch {\n setError(verify\n ? t('portal.verify.error.generic', 'Email verification failed. Please try again.')\n : t('portal.resetPassword.error.generic', 'Password reset failed. Please try again.'))\n } finally {\n setSubmitting(false)\n }\n },\n [token, password, confirmPassword, t, verify, noTokenMessage],\n )\n\n if (tenant.loading) {\n return <div className=\"flex items-center justify-center py-20\"><Spinner /></div>\n }\n\n if (tenant.error) {\n return (\n <div className=\"mx-auto w-full max-w-md py-12\">\n <EmptyState\n variant=\"subtle\"\n size=\"lg\"\n icon={<SearchX className=\"h-6 w-6\" aria-hidden />}\n title={t('portal.org.invalid', 'Organization not found.')}\n />\n </div>\n )\n }\n\n if (success) {\n return (\n <div className=\"mx-auto w-full max-w-sm\">\n <div className=\"mb-8 text-center\">\n <h1 className=\"text-2xl font-bold tracking-tight\">{verify\n ? t('portal.verify.success.title', 'Email verified')\n : t('portal.resetPassword.success.title', 'Password Reset Complete')}</h1>\n <p className=\"mt-1.5 text-sm text-muted-foreground\">{verify\n ? t('portal.verify.success.description', 'Your email has been verified. You can now sign in to the portal.')\n : t('portal.resetPassword.success.description', 'Your password has been successfully reset.')}</p>\n </div>\n\n <Alert>\n <AlertDescription>{t('portal.resetPassword.success.message', 'You can now sign in with your new password.')}</AlertDescription>\n </Alert>\n\n <div className=\"mt-6 text-center\">\n <Link href={`/${orgSlug}/portal/login`} className=\"font-medium text-foreground underline underline-offset-4 hover:opacity-80\">\n {t('portal.resetPassword.success.loginLink', 'Go to Sign In')}\n </Link>\n </div>\n </div>\n )\n }\n\n return (\n <div className=\"mx-auto w-full max-w-sm\">\n <div className=\"mb-8 text-center\">\n <h1 className=\"text-2xl font-bold tracking-tight\">{verify\n ? t('portal.verify.title', 'Verify email')\n : t('portal.resetPassword.title', 'Reset Password')}</h1>\n <p className=\"mt-1.5 text-sm text-muted-foreground\">{t('portal.resetPassword.description', 'Enter your new password below.')}</p>\n </div>\n\n {beforeForm}\n\n <form onSubmit={handleSubmit} className=\"flex flex-col gap-4\">\n {error ? (\n <Alert status=\"error\">\n <AlertDescription>{error}</AlertDescription>\n </Alert>\n ) : null}\n\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor=\"reset-password\" className=\"text-overline font-semibold uppercase tracking-wider text-muted-foreground/70\">{t('portal.resetPassword.password', 'New Password')}</Label>\n <PasswordInput id=\"reset-password\" autoComplete=\"new-password\" required placeholder={t('portal.resetPassword.password.placeholder', '\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022')} value={password} onChange={(e) => setPassword(e.target.value)} disabled={submitting || !token} className=\"rounded-lg\" />\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor=\"confirm-password\" className=\"text-overline font-semibold uppercase tracking-wider text-muted-foreground/70\">{t('portal.resetPassword.confirmPassword', 'Confirm New Password')}</Label>\n <PasswordInput id=\"confirm-password\" autoComplete=\"new-password\" required placeholder={t('portal.resetPassword.confirmPassword.placeholder', '\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022')} value={confirmPassword} onChange={(e) => setConfirmPassword(e.target.value)} disabled={submitting || !token} className=\"rounded-lg\" />\n </div>\n\n <Button type=\"submit\" disabled={submitting || !token} className=\"mt-1 w-full rounded-lg\">\n {verify\n ? t('portal.verify.submit', 'Verify email and set password')\n : submitting ? t('portal.resetPassword.submitting', 'Resetting password...') : t('portal.resetPassword.submit', 'Reset Password')}\n </Button>\n\n <p className=\"text-center text-sm text-muted-foreground\">\n {verify ? null : t('portal.resetPassword.backToLogin', 'Remember your password?')}{' '}\n <Link href={`/${orgSlug}/portal/login`} className=\"font-medium text-foreground underline underline-offset-4 hover:opacity-80\">\n {t('portal.resetPassword.loginLink', 'Sign in')}\n </Link>\n </p>\n </form>\n\n {afterForm}\n </div>\n )\n}\n"],
|
|
5
|
+
"mapp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sBAAsB,GAAE;AAAA,QAC/L,oBAAC,iBAAc,IAAG,oBAAmB,cAAa,gBAAe,UAAQ,MAAC,aAAa,EAAE,oDAAoD,kDAAU,GAAG,OAAO,iBAAiB,UAAU,CAAC,MAAM,mBAAmB,EAAE,OAAO,KAAK,GAAG,UAAU,cAAc,CAAC,OAAO,WAAU,cAAa;AAAA,SAChS;AAAA,MAEA,oBAAC,UAAO,MAAK,UAAS,UAAU,cAAc,CAAC,OAAO,WAAU,0BAC7D,mBACG,EAAE,wBAAwB,+BAA+B,IACzD,aAAa,EAAE,mCAAmC,uBAAuB,IAAI,EAAE,+BAA+B,gBAAgB,GACpI;AAAA,MAEA,qBAAC,OAAE,WAAU,6CACV;AAAA,iBAAS,OAAO,EAAE,oCAAoC,yBAAyB;AAAA,QAAG;AAAA,QACnF,oBAAC,QAAK,MAAM,IAAI,OAAO,iBAAiB,WAAU,6EAC/C,YAAE,kCAAkC,SAAS,GAChD;AAAA,SACF;AAAA,OACF;AAAA,IAEC;AAAA,KACH;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,132 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx
|
|
3
|
-
import {
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
4
|
import { extensionPoints } from "@open-mercato/core/modules/portal/extension-points";
|
|
5
|
-
import { useSearchParams } from "next/navigation";
|
|
6
|
-
import Link from "next/link";
|
|
7
|
-
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
8
|
-
import { PasswordInput } from "@open-mercato/ui/primitives/password-input";
|
|
9
|
-
import { Label } from "@open-mercato/ui/primitives/label";
|
|
10
|
-
import { Button } from "@open-mercato/ui/primitives/button";
|
|
11
|
-
import { Alert, AlertDescription } from "@open-mercato/ui/primitives/alert";
|
|
12
|
-
import { EmptyState } from "@open-mercato/ui/primitives/empty-state";
|
|
13
|
-
import { SearchX } from "lucide-react";
|
|
14
|
-
import { Spinner } from "@open-mercato/ui/primitives/spinner";
|
|
15
|
-
import { apiCall } from "@open-mercato/ui/backend/utils/apiCall";
|
|
16
|
-
import { usePortalContext } from "@open-mercato/ui/portal/PortalContext";
|
|
17
5
|
import { InjectionSpot } from "@open-mercato/ui/backend/injection/InjectionSpot";
|
|
6
|
+
import { PortalPasswordForm } from "../PasswordForm.js";
|
|
18
7
|
function PortalResetPasswordPage({ params }) {
|
|
19
|
-
const t = useT();
|
|
20
8
|
const orgSlug = params.orgSlug;
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const [token, setToken] = useState(null);
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
const tokenParam = searchParams.get("token");
|
|
31
|
-
if (!tokenParam) {
|
|
32
|
-
setError(t("portal.resetPassword.error.noToken", "Invalid or missing reset token."));
|
|
33
|
-
} else {
|
|
34
|
-
setToken(tokenParam);
|
|
9
|
+
const injectionContext = useMemo(() => ({ orgSlug }), [orgSlug]);
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
11
|
+
PortalPasswordForm,
|
|
12
|
+
{
|
|
13
|
+
params,
|
|
14
|
+
beforeForm: /* @__PURE__ */ jsx(InjectionSpot, { spotId: extensionPoints.hosts.resetPasswordBefore.spotId, context: injectionContext }),
|
|
15
|
+
afterForm: /* @__PURE__ */ jsx(InjectionSpot, { spotId: extensionPoints.hosts.resetPasswordAfter.spotId, context: injectionContext })
|
|
35
16
|
}
|
|
36
|
-
}, [searchParams, t]);
|
|
37
|
-
const handleSubmit = useCallback(
|
|
38
|
-
async (event) => {
|
|
39
|
-
event.preventDefault();
|
|
40
|
-
setError(null);
|
|
41
|
-
if (!token) {
|
|
42
|
-
setError(t("portal.resetPassword.error.noToken", "Invalid or missing reset token."));
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (password !== confirmPassword) {
|
|
46
|
-
setError(t("portal.resetPassword.error.passwordMismatch", "Passwords do not match."));
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (password.length < 8) {
|
|
50
|
-
setError(t("portal.resetPassword.error.passwordTooShort", "Password must be at least 8 characters long."));
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
setSubmitting(true);
|
|
54
|
-
try {
|
|
55
|
-
const result = await apiCall("/api/customer_accounts/password/reset-confirm", {
|
|
56
|
-
method: "POST",
|
|
57
|
-
headers: { "Content-Type": "application/json" },
|
|
58
|
-
body: JSON.stringify({ token, password })
|
|
59
|
-
});
|
|
60
|
-
if (result.ok && result.result?.ok) {
|
|
61
|
-
setSuccess(true);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
if (result.status === 400) {
|
|
65
|
-
setError(t("portal.resetPassword.error.invalidToken", "Invalid or expired reset token."));
|
|
66
|
-
} else {
|
|
67
|
-
setError(result.result?.error || t("portal.resetPassword.error.generic", "Password reset failed. Please try again."));
|
|
68
|
-
}
|
|
69
|
-
} catch {
|
|
70
|
-
setError(t("portal.resetPassword.error.generic", "Password reset failed. Please try again."));
|
|
71
|
-
} finally {
|
|
72
|
-
setSubmitting(false);
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
[token, password, confirmPassword, t]
|
|
76
17
|
);
|
|
77
|
-
const injectionContext = useMemo(
|
|
78
|
-
() => ({ orgSlug }),
|
|
79
|
-
[orgSlug]
|
|
80
|
-
);
|
|
81
|
-
if (tenant.loading) {
|
|
82
|
-
return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-20", children: /* @__PURE__ */ jsx(Spinner, {}) });
|
|
83
|
-
}
|
|
84
|
-
if (tenant.error) {
|
|
85
|
-
return /* @__PURE__ */ jsx("div", { className: "mx-auto w-full max-w-md py-12", children: /* @__PURE__ */ jsx(
|
|
86
|
-
EmptyState,
|
|
87
|
-
{
|
|
88
|
-
variant: "subtle",
|
|
89
|
-
size: "lg",
|
|
90
|
-
icon: /* @__PURE__ */ jsx(SearchX, { className: "h-6 w-6", "aria-hidden": true }),
|
|
91
|
-
title: t("portal.org.invalid", "Organization not found.")
|
|
92
|
-
}
|
|
93
|
-
) });
|
|
94
|
-
}
|
|
95
|
-
if (success) {
|
|
96
|
-
return /* @__PURE__ */ jsxs("div", { className: "mx-auto w-full max-w-sm", children: [
|
|
97
|
-
/* @__PURE__ */ jsxs("div", { className: "mb-8 text-center", children: [
|
|
98
|
-
/* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold tracking-tight", children: t("portal.resetPassword.success.title", "Password Reset Complete") }),
|
|
99
|
-
/* @__PURE__ */ jsx("p", { className: "mt-1.5 text-sm text-muted-foreground", children: t("portal.resetPassword.success.description", "Your password has been successfully reset.") })
|
|
100
|
-
] }),
|
|
101
|
-
/* @__PURE__ */ jsx(Alert, { children: /* @__PURE__ */ jsx(AlertDescription, { children: t("portal.resetPassword.success.message", "You can now sign in with your new password.") }) }),
|
|
102
|
-
/* @__PURE__ */ jsx("div", { className: "mt-6 text-center", children: /* @__PURE__ */ jsx(Link, { href: `/${orgSlug}/portal/login`, className: "font-medium text-foreground underline underline-offset-4 hover:opacity-80", children: t("portal.resetPassword.success.loginLink", "Go to Sign In") }) })
|
|
103
|
-
] });
|
|
104
|
-
}
|
|
105
|
-
return /* @__PURE__ */ jsxs("div", { className: "mx-auto w-full max-w-sm", children: [
|
|
106
|
-
/* @__PURE__ */ jsxs("div", { className: "mb-8 text-center", children: [
|
|
107
|
-
/* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold tracking-tight", children: t("portal.resetPassword.title", "Reset Password") }),
|
|
108
|
-
/* @__PURE__ */ jsx("p", { className: "mt-1.5 text-sm text-muted-foreground", children: t("portal.resetPassword.description", "Enter your new password below.") })
|
|
109
|
-
] }),
|
|
110
|
-
/* @__PURE__ */ jsx(InjectionSpot, { spotId: extensionPoints.hosts.resetPasswordBefore.spotId, context: injectionContext }),
|
|
111
|
-
/* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "flex flex-col gap-4", children: [
|
|
112
|
-
error ? /* @__PURE__ */ jsx(Alert, { status: "error", children: /* @__PURE__ */ jsx(AlertDescription, { children: error }) }) : null,
|
|
113
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
114
|
-
/* @__PURE__ */ jsx(Label, { htmlFor: "reset-password", className: "text-overline font-semibold uppercase tracking-wider text-muted-foreground/70", children: t("portal.resetPassword.password", "New Password") }),
|
|
115
|
-
/* @__PURE__ */ jsx(PasswordInput, { id: "reset-password", autoComplete: "new-password", required: true, placeholder: t("portal.resetPassword.password.placeholder", "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"), value: password, onChange: (e) => setPassword(e.target.value), disabled: submitting || !token, className: "rounded-lg" })
|
|
116
|
-
] }),
|
|
117
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
118
|
-
/* @__PURE__ */ jsx(Label, { htmlFor: "confirm-password", className: "text-overline font-semibold uppercase tracking-wider text-muted-foreground/70", children: t("portal.resetPassword.confirmPassword", "Confirm New Password") }),
|
|
119
|
-
/* @__PURE__ */ jsx(PasswordInput, { id: "confirm-password", autoComplete: "new-password", required: true, placeholder: t("portal.resetPassword.confirmPassword.placeholder", "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"), value: confirmPassword, onChange: (e) => setConfirmPassword(e.target.value), disabled: submitting || !token, className: "rounded-lg" })
|
|
120
|
-
] }),
|
|
121
|
-
/* @__PURE__ */ jsx(Button, { type: "submit", disabled: submitting || !token, className: "mt-1 w-full rounded-lg", children: submitting ? t("portal.resetPassword.submitting", "Resetting password...") : t("portal.resetPassword.submit", "Reset Password") }),
|
|
122
|
-
/* @__PURE__ */ jsxs("p", { className: "text-center text-sm text-muted-foreground", children: [
|
|
123
|
-
t("portal.resetPassword.backToLogin", "Remember your password?"),
|
|
124
|
-
" ",
|
|
125
|
-
/* @__PURE__ */ jsx(Link, { href: `/${orgSlug}/portal/login`, className: "font-medium text-foreground underline underline-offset-4 hover:opacity-80", children: t("portal.resetPassword.loginLink", "Sign in") })
|
|
126
|
-
] })
|
|
127
|
-
] }),
|
|
128
|
-
/* @__PURE__ */ jsx(InjectionSpot, { spotId: extensionPoints.hosts.resetPasswordAfter.spotId, context: injectionContext })
|
|
129
|
-
] });
|
|
130
18
|
}
|
|
131
19
|
export {
|
|
132
20
|
PortalResetPasswordPage as default
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/portal/frontend/%5BorgSlug%5D/portal/reset-password/page.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\nimport {
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport { useMemo } from 'react'\nimport { extensionPoints } from '@open-mercato/core/modules/portal/extension-points'\nimport { InjectionSpot } from '@open-mercato/ui/backend/injection/InjectionSpot'\nimport { PortalPasswordForm } from '../PasswordForm'\n\nexport default function PortalResetPasswordPage({ params }: { params: { orgSlug: string } }) {\n const orgSlug = params.orgSlug\n const injectionContext = useMemo(() => ({ orgSlug }), [orgSlug])\n return (\n <PortalPasswordForm\n params={params}\n beforeForm={<InjectionSpot spotId={extensionPoints.hosts.resetPasswordBefore.spotId} context={injectionContext} />}\n afterForm={<InjectionSpot spotId={extensionPoints.hosts.resetPasswordAfter.spotId} context={injectionContext} />}\n />\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAYkB;AAXlB,SAAS,eAAe;AACxB,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAC9B,SAAS,0BAA0B;AAEpB,SAAR,wBAAyC,EAAE,OAAO,GAAoC;AAC3F,QAAM,UAAU,OAAO;AACvB,QAAM,mBAAmB,QAAQ,OAAO,EAAE,QAAQ,IAAI,CAAC,OAAO,CAAC;AAC/D,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,YAAY,oBAAC,iBAAc,QAAQ,gBAAgB,MAAM,oBAAoB,QAAQ,SAAS,kBAAkB;AAAA,MAChH,WAAW,oBAAC,iBAAc,QAAQ,gBAAgB,MAAM,mBAAmB,QAAQ,SAAS,kBAAkB;AAAA;AAAA,EAChH;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -6,7 +6,6 @@ import Link from "next/link";
|
|
|
6
6
|
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
7
7
|
import { Input } from "@open-mercato/ui/primitives/input";
|
|
8
8
|
import { EmailInput } from "@open-mercato/ui/primitives/email-input";
|
|
9
|
-
import { PasswordInput } from "@open-mercato/ui/primitives/password-input";
|
|
10
9
|
import { Label } from "@open-mercato/ui/primitives/label";
|
|
11
10
|
import { Button } from "@open-mercato/ui/primitives/button";
|
|
12
11
|
import { Alert, AlertDescription } from "@open-mercato/ui/primitives/alert";
|
|
@@ -22,7 +21,6 @@ function PortalSignupPage({ params }) {
|
|
|
22
21
|
const { tenant } = usePortalContext();
|
|
23
22
|
const [displayName, setDisplayName] = useState("");
|
|
24
23
|
const [email, setEmail] = useState("");
|
|
25
|
-
const [password, setPassword] = useState("");
|
|
26
24
|
const [error, setError] = useState(null);
|
|
27
25
|
const [fieldErrors, setFieldErrors] = useState({});
|
|
28
26
|
const [success, setSuccess] = useState(false);
|
|
@@ -41,7 +39,7 @@ function PortalSignupPage({ params }) {
|
|
|
41
39
|
const result = await apiCall("/api/customer_accounts/signup", {
|
|
42
40
|
method: "POST",
|
|
43
41
|
headers: { "Content-Type": "application/json" },
|
|
44
|
-
body: JSON.stringify({ email,
|
|
42
|
+
body: JSON.stringify({ email, displayName, organizationId: tenant.organizationId })
|
|
45
43
|
});
|
|
46
44
|
if (result.status === 202 && result.result?.ok) {
|
|
47
45
|
setSuccess(true);
|
|
@@ -56,8 +54,6 @@ function PortalSignupPage({ params }) {
|
|
|
56
54
|
mapped.displayName = t("portal.signup.error.displayName.required", "Full name is required.");
|
|
57
55
|
} else if (fieldKey === "email") {
|
|
58
56
|
mapped.email = t("portal.signup.error.email.invalid", "Please enter a valid email address.");
|
|
59
|
-
} else if (fieldKey === "password") {
|
|
60
|
-
mapped.password = t("portal.signup.error.password.minLength", "Password must be at least 8 characters.");
|
|
61
57
|
}
|
|
62
58
|
}
|
|
63
59
|
const hasUnmappedField = detailEntries.some(([fieldKey]) => !(fieldKey in mapped));
|
|
@@ -74,7 +70,7 @@ function PortalSignupPage({ params }) {
|
|
|
74
70
|
setSubmitting(false);
|
|
75
71
|
}
|
|
76
72
|
},
|
|
77
|
-
[displayName, email,
|
|
73
|
+
[displayName, email, tenant.organizationId, t]
|
|
78
74
|
);
|
|
79
75
|
const injectionContext = useMemo(
|
|
80
76
|
() => ({ orgSlug }),
|
|
@@ -123,11 +119,6 @@ function PortalSignupPage({ params }) {
|
|
|
123
119
|
/* @__PURE__ */ jsx(EmailInput, { id: "signup-email", required: true, placeholder: t("portal.signup.email.placeholder", "you@example.com"), value: email, onChange: (e) => setEmail(e.target.value), disabled: submitting, "aria-invalid": fieldErrors.email ? true : void 0, "aria-describedby": fieldErrors.email ? "signup-email-error" : void 0, className: "rounded-lg" }),
|
|
124
120
|
fieldErrors.email && /* @__PURE__ */ jsx("p", { id: "signup-email-error", role: "alert", className: "text-sm text-destructive", children: fieldErrors.email })
|
|
125
121
|
] }),
|
|
126
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
127
|
-
/* @__PURE__ */ jsx(Label, { htmlFor: "signup-password", className: "text-overline font-semibold uppercase tracking-wider text-muted-foreground/70", children: t("portal.signup.password", "Password") }),
|
|
128
|
-
/* @__PURE__ */ jsx(PasswordInput, { id: "signup-password", autoComplete: "new-password", required: true, placeholder: t("portal.signup.password.placeholder", "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"), value: password, onChange: (e) => setPassword(e.target.value), disabled: submitting, "aria-invalid": fieldErrors.password ? true : void 0, "aria-describedby": fieldErrors.password ? "signup-password-error" : void 0, className: "rounded-lg" }),
|
|
129
|
-
fieldErrors.password && /* @__PURE__ */ jsx("p", { id: "signup-password-error", role: "alert", className: "text-sm text-destructive", children: fieldErrors.password })
|
|
130
|
-
] }),
|
|
131
122
|
/* @__PURE__ */ jsx(Button, { type: "submit", disabled: submitting, className: "mt-1 w-full rounded-lg", children: submitting ? t("portal.signup.submitting", "Creating account...") : t("portal.signup.submit", "Create Account") }),
|
|
132
123
|
/* @__PURE__ */ jsxs("p", { className: "text-center text-sm text-muted-foreground", children: [
|
|
133
124
|
t("portal.signup.hasAccount", "Already have an account?"),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/portal/frontend/%5BorgSlug%5D/portal/signup/page.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\nimport { useCallback, useMemo, useState } from 'react'\nimport { extensionPoints } from '@open-mercato/core/modules/portal/extension-points'\nimport Link from 'next/link'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { EmailInput } from '@open-mercato/ui/primitives/email-input'\nimport {
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport { useCallback, useMemo, useState } from 'react'\nimport { extensionPoints } from '@open-mercato/core/modules/portal/extension-points'\nimport Link from 'next/link'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { EmailInput } from '@open-mercato/ui/primitives/email-input'\nimport { Label } from '@open-mercato/ui/primitives/label'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Alert, AlertDescription } from '@open-mercato/ui/primitives/alert'\nimport { EmptyState } from '@open-mercato/ui/primitives/empty-state'\nimport { SearchX, Check } from 'lucide-react'\nimport { Spinner } from '@open-mercato/ui/primitives/spinner'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { usePortalContext } from '@open-mercato/ui/portal/PortalContext'\nimport { InjectionSpot } from '@open-mercato/ui/backend/injection/InjectionSpot'\n\ntype Props = { params: { orgSlug: string } }\ntype SignupResponse = { ok: boolean; error?: string; details?: Record<string, string[]> }\n\nexport default function PortalSignupPage({ params }: Props) {\n const t = useT()\n const orgSlug = params.orgSlug\n const { tenant } = usePortalContext()\n\n const [displayName, setDisplayName] = useState('')\n const [email, setEmail] = useState('')\n const [error, setError] = useState<string | null>(null)\n const [fieldErrors, setFieldErrors] = useState<Record<string, string>>({})\n const [success, setSuccess] = useState(false)\n const [submitting, setSubmitting] = useState(false)\n\n const handleSubmit = useCallback(\n async (event: React.FormEvent) => {\n event.preventDefault()\n setError(null)\n setFieldErrors({})\n\n if (!tenant.organizationId) {\n setError(t('portal.org.invalid', 'Organization not found.'))\n return\n }\n\n setSubmitting(true)\n try {\n const result = await apiCall<SignupResponse>('/api/customer_accounts/signup', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ email, displayName, organizationId: tenant.organizationId }),\n })\n\n if (result.status === 202 && result.result?.ok) {\n setSuccess(true)\n return\n }\n\n const details = result.result?.details\n const detailEntries = details ? Object.entries(details).filter(([, messages]) => (messages?.length ?? 0) > 0) : []\n if (detailEntries.length > 0) {\n // API detail values are raw untranslated validator strings; each known field maps to one translated message instead.\n const mapped: Record<string, string> = {}\n for (const [fieldKey] of detailEntries) {\n if (fieldKey === 'displayName') {\n mapped.displayName = t('portal.signup.error.displayName.required', 'Full name is required.')\n } else if (fieldKey === 'email') {\n mapped.email = t('portal.signup.error.email.invalid', 'Please enter a valid email address.')\n }\n }\n const hasUnmappedField = detailEntries.some(([fieldKey]) => !(fieldKey in mapped))\n setFieldErrors(mapped)\n if (hasUnmappedField || Object.keys(mapped).length === 0) {\n setError(result.result?.error || t('portal.signup.error.generic', 'Signup failed. Please try again.'))\n }\n } else {\n setError(result.result?.error || t('portal.signup.error.generic', 'Signup failed. Please try again.'))\n }\n } catch {\n setError(t('portal.signup.error.generic', 'Signup failed. Please try again.'))\n } finally {\n setSubmitting(false)\n }\n },\n [displayName, email, tenant.organizationId, t],\n )\n\n const injectionContext = useMemo(\n () => ({ orgSlug }),\n [orgSlug],\n )\n\n if (tenant.loading) {\n return <div className=\"flex items-center justify-center py-20\"><Spinner /></div>\n }\n\n if (tenant.error) {\n return (\n <div className=\"mx-auto w-full max-w-md py-12\">\n <EmptyState\n variant=\"subtle\"\n size=\"lg\"\n icon={<SearchX className=\"h-6 w-6\" aria-hidden />}\n title={t('portal.org.invalid', 'Organization not found.')}\n />\n </div>\n )\n }\n\n if (success) {\n return (\n <div className=\"mx-auto w-full max-w-sm text-center\">\n <div className=\"mx-auto mb-4 flex size-12 items-center justify-center rounded-full bg-foreground text-background\">\n <Check className=\"size-6\" />\n </div>\n <h1 className=\"text-2xl font-bold tracking-tight\">{t('portal.signup.success.title', 'Check your email')}</h1>\n <p className=\"mt-1.5 text-sm text-muted-foreground\">{t(\n 'portal.signup.success.description',\n 'If your registration was accepted, check your email for next steps before signing in. Some organizations require an administrator to activate new accounts.',\n )}</p>\n <Button asChild className=\"mt-6 w-full rounded-lg\">\n <Link href={`/${orgSlug}/portal/login`}>{t('portal.signup.success.loginLink', 'Sign In')}</Link>\n </Button>\n </div>\n )\n }\n\n return (\n <div className=\"mx-auto w-full max-w-sm\">\n <div className=\"mb-8 text-center\">\n <h1 className=\"text-2xl font-bold tracking-tight\">{t('portal.signup.title', 'Create Account')}</h1>\n <p className=\"mt-1.5 text-sm text-muted-foreground\">{t('portal.signup.description', 'Sign up for a portal account.')}</p>\n </div>\n\n <InjectionSpot spotId={extensionPoints.hosts.signupBefore.spotId} context={injectionContext} />\n\n <form onSubmit={handleSubmit} className=\"flex flex-col gap-4\">\n {error ? (\n <Alert status=\"error\">\n <AlertDescription>{error}</AlertDescription>\n </Alert>\n ) : null}\n\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor=\"signup-name\" className=\"text-overline font-semibold uppercase tracking-wider text-muted-foreground/70\">{t('portal.signup.displayName', 'Full Name')}</Label>\n <Input id=\"signup-name\" type=\"text\" autoComplete=\"name\" required placeholder={t('portal.signup.displayName.placeholder', 'Jane Smith')} value={displayName} onChange={(e) => setDisplayName(e.target.value)} disabled={submitting} aria-invalid={fieldErrors.displayName ? true : undefined} aria-describedby={fieldErrors.displayName ? 'signup-name-error' : undefined} className=\"rounded-lg\" />\n {fieldErrors.displayName && <p id=\"signup-name-error\" role=\"alert\" className=\"text-sm text-destructive\">{fieldErrors.displayName}</p>}\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor=\"signup-email\" className=\"text-overline font-semibold uppercase tracking-wider text-muted-foreground/70\">{t('portal.signup.email', 'Email')}</Label>\n <EmailInput id=\"signup-email\" required placeholder={t('portal.signup.email.placeholder', 'you@example.com')} value={email} onChange={(e) => setEmail(e.target.value)} disabled={submitting} aria-invalid={fieldErrors.email ? true : undefined} aria-describedby={fieldErrors.email ? 'signup-email-error' : undefined} className=\"rounded-lg\" />\n {fieldErrors.email && <p id=\"signup-email-error\" role=\"alert\" className=\"text-sm text-destructive\">{fieldErrors.email}</p>}\n </div>\n\n <Button type=\"submit\" disabled={submitting} className=\"mt-1 w-full rounded-lg\">\n {submitting ? t('portal.signup.submitting', 'Creating account...') : t('portal.signup.submit', 'Create Account')}\n </Button>\n\n <p className=\"text-center text-sm text-muted-foreground\">\n {t('portal.signup.hasAccount', 'Already have an account?')}{' '}\n <Link href={`/${orgSlug}/portal/login`} className=\"font-medium text-foreground underline underline-offset-4 hover:opacity-80\">\n {t('portal.signup.loginLink', 'Sign in')}\n </Link>\n </p>\n </form>\n\n <InjectionSpot spotId={extensionPoints.hosts.signupAfter.spotId} context={injectionContext} />\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA2FmE,cAkB7D,YAlB6D;AA1FnE,SAAS,aAAa,SAAS,gBAAgB;AAC/C,SAAS,uBAAuB;AAChC,OAAO,UAAU;AACjB,SAAS,YAAY;AAC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