payload 3.49.0-canary.8 → 3.49.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.
Files changed (142) hide show
  1. package/dist/admin/elements/Cell.d.ts +2 -0
  2. package/dist/admin/elements/Cell.d.ts.map +1 -1
  3. package/dist/admin/elements/Cell.js.map +1 -1
  4. package/dist/admin/forms/Form.d.ts +1 -0
  5. package/dist/admin/forms/Form.d.ts.map +1 -1
  6. package/dist/admin/forms/Form.js.map +1 -1
  7. package/dist/admin/views/index.d.ts +2 -1
  8. package/dist/admin/views/index.d.ts.map +1 -1
  9. package/dist/admin/views/index.js.map +1 -1
  10. package/dist/admin/views/list.d.ts +4 -1
  11. package/dist/admin/views/list.d.ts.map +1 -1
  12. package/dist/admin/views/list.js.map +1 -1
  13. package/dist/auth/operations/forgotPassword.d.ts.map +1 -1
  14. package/dist/auth/operations/forgotPassword.js +7 -0
  15. package/dist/auth/operations/forgotPassword.js.map +1 -1
  16. package/dist/auth/operations/init.d.ts.map +1 -1
  17. package/dist/auth/operations/init.js +10 -1
  18. package/dist/auth/operations/init.js.map +1 -1
  19. package/dist/auth/operations/local/login.d.ts +1 -0
  20. package/dist/auth/operations/local/login.d.ts.map +1 -1
  21. package/dist/auth/operations/local/login.js.map +1 -1
  22. package/dist/auth/operations/login.d.ts.map +1 -1
  23. package/dist/auth/operations/login.js +7 -0
  24. package/dist/auth/operations/login.js.map +1 -1
  25. package/dist/auth/operations/logout.d.ts.map +1 -1
  26. package/dist/auth/operations/logout.js +9 -3
  27. package/dist/auth/operations/logout.js.map +1 -1
  28. package/dist/auth/operations/registerFirstUser.d.ts.map +1 -1
  29. package/dist/auth/operations/registerFirstUser.js +8 -1
  30. package/dist/auth/operations/registerFirstUser.js.map +1 -1
  31. package/dist/auth/operations/resetPassword.d.ts.map +1 -1
  32. package/dist/auth/operations/resetPassword.js +11 -4
  33. package/dist/auth/operations/resetPassword.js.map +1 -1
  34. package/dist/auth/operations/unlock.d.ts.map +1 -1
  35. package/dist/auth/operations/unlock.js +7 -0
  36. package/dist/auth/operations/unlock.js.map +1 -1
  37. package/dist/auth/operations/verifyEmail.d.ts.map +1 -1
  38. package/dist/auth/operations/verifyEmail.js +9 -3
  39. package/dist/auth/operations/verifyEmail.js.map +1 -1
  40. package/dist/collections/config/sanitize.d.ts.map +1 -1
  41. package/dist/collections/config/sanitize.js +17 -1
  42. package/dist/collections/config/sanitize.js.map +1 -1
  43. package/dist/collections/config/types.d.ts +15 -2
  44. package/dist/collections/config/types.d.ts.map +1 -1
  45. package/dist/collections/config/types.js.map +1 -1
  46. package/dist/collections/endpoints/delete.d.ts.map +1 -1
  47. package/dist/collections/endpoints/delete.js +2 -1
  48. package/dist/collections/endpoints/delete.js.map +1 -1
  49. package/dist/collections/endpoints/deleteByID.d.ts.map +1 -1
  50. package/dist/collections/endpoints/deleteByID.js +3 -1
  51. package/dist/collections/endpoints/deleteByID.js.map +1 -1
  52. package/dist/collections/endpoints/find.d.ts.map +1 -1
  53. package/dist/collections/endpoints/find.js +2 -1
  54. package/dist/collections/endpoints/find.js.map +1 -1
  55. package/dist/collections/endpoints/findByID.d.ts.map +1 -1
  56. package/dist/collections/endpoints/findByID.js +3 -1
  57. package/dist/collections/endpoints/findByID.js.map +1 -1
  58. package/dist/collections/endpoints/findVersionByID.d.ts.map +1 -1
  59. package/dist/collections/endpoints/findVersionByID.js +3 -1
  60. package/dist/collections/endpoints/findVersionByID.js.map +1 -1
  61. package/dist/collections/endpoints/findVersions.d.ts.map +1 -1
  62. package/dist/collections/endpoints/findVersions.js +2 -1
  63. package/dist/collections/endpoints/findVersions.js.map +1 -1
  64. package/dist/collections/endpoints/preview.d.ts.map +1 -1
  65. package/dist/collections/endpoints/preview.js +2 -1
  66. package/dist/collections/endpoints/preview.js.map +1 -1
  67. package/dist/collections/endpoints/update.d.ts.map +1 -1
  68. package/dist/collections/endpoints/update.js +2 -1
  69. package/dist/collections/endpoints/update.js.map +1 -1
  70. package/dist/collections/endpoints/updateByID.d.ts.map +1 -1
  71. package/dist/collections/endpoints/updateByID.js +3 -1
  72. package/dist/collections/endpoints/updateByID.js.map +1 -1
  73. package/dist/collections/operations/delete.d.ts +1 -0
  74. package/dist/collections/operations/delete.d.ts.map +1 -1
  75. package/dist/collections/operations/delete.js +9 -2
  76. package/dist/collections/operations/delete.js.map +1 -1
  77. package/dist/collections/operations/deleteByID.d.ts +1 -0
  78. package/dist/collections/operations/deleteByID.d.ts.map +1 -1
  79. package/dist/collections/operations/deleteByID.js +14 -6
  80. package/dist/collections/operations/deleteByID.js.map +1 -1
  81. package/dist/collections/operations/find.d.ts +1 -0
  82. package/dist/collections/operations/find.d.ts.map +1 -1
  83. package/dist/collections/operations/find.js +8 -1
  84. package/dist/collections/operations/find.js.map +1 -1
  85. package/dist/collections/operations/findByID.d.ts +1 -0
  86. package/dist/collections/operations/findByID.d.ts.map +1 -1
  87. package/dist/collections/operations/findByID.js +9 -2
  88. package/dist/collections/operations/findByID.js.map +1 -1
  89. package/dist/collections/operations/findVersionByID.d.ts +1 -0
  90. package/dist/collections/operations/findVersionByID.d.ts.map +1 -1
  91. package/dist/collections/operations/findVersionByID.js +11 -3
  92. package/dist/collections/operations/findVersionByID.js.map +1 -1
  93. package/dist/collections/operations/findVersions.d.ts +1 -0
  94. package/dist/collections/operations/findVersions.d.ts.map +1 -1
  95. package/dist/collections/operations/findVersions.js +10 -2
  96. package/dist/collections/operations/findVersions.js.map +1 -1
  97. package/dist/collections/operations/local/delete.d.ts +8 -0
  98. package/dist/collections/operations/local/delete.d.ts.map +1 -1
  99. package/dist/collections/operations/local/delete.js +2 -1
  100. package/dist/collections/operations/local/delete.js.map +1 -1
  101. package/dist/collections/operations/local/find.d.ts +9 -0
  102. package/dist/collections/operations/local/find.d.ts.map +1 -1
  103. package/dist/collections/operations/local/find.js +2 -1
  104. package/dist/collections/operations/local/find.js.map +1 -1
  105. package/dist/collections/operations/local/findByID.d.ts +9 -0
  106. package/dist/collections/operations/local/findByID.d.ts.map +1 -1
  107. package/dist/collections/operations/local/findByID.js +3 -2
  108. package/dist/collections/operations/local/findByID.js.map +1 -1
  109. package/dist/collections/operations/local/findVersionByID.d.ts +9 -0
  110. package/dist/collections/operations/local/findVersionByID.d.ts.map +1 -1
  111. package/dist/collections/operations/local/findVersionByID.js +4 -3
  112. package/dist/collections/operations/local/findVersionByID.js.map +1 -1
  113. package/dist/collections/operations/local/findVersions.d.ts +9 -0
  114. package/dist/collections/operations/local/findVersions.d.ts.map +1 -1
  115. package/dist/collections/operations/local/findVersions.js +3 -2
  116. package/dist/collections/operations/local/findVersions.js.map +1 -1
  117. package/dist/collections/operations/local/update.d.ts +7 -0
  118. package/dist/collections/operations/local/update.d.ts.map +1 -1
  119. package/dist/collections/operations/local/update.js +2 -1
  120. package/dist/collections/operations/local/update.js.map +1 -1
  121. package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
  122. package/dist/collections/operations/restoreVersion.js +3 -0
  123. package/dist/collections/operations/restoreVersion.js.map +1 -1
  124. package/dist/collections/operations/update.d.ts +1 -0
  125. package/dist/collections/operations/update.d.ts.map +1 -1
  126. package/dist/collections/operations/update.js +17 -2
  127. package/dist/collections/operations/update.js.map +1 -1
  128. package/dist/collections/operations/updateByID.d.ts +1 -0
  129. package/dist/collections/operations/updateByID.d.ts.map +1 -1
  130. package/dist/collections/operations/updateByID.js +22 -6
  131. package/dist/collections/operations/updateByID.js.map +1 -1
  132. package/dist/database/getLocalizedPaths.d.ts.map +1 -1
  133. package/dist/database/getLocalizedPaths.js +6 -7
  134. package/dist/database/getLocalizedPaths.js.map +1 -1
  135. package/dist/utilities/appendNonTrashedFilter.d.ts +8 -0
  136. package/dist/utilities/appendNonTrashedFilter.d.ts.map +1 -0
  137. package/dist/utilities/appendNonTrashedFilter.js +29 -0
  138. package/dist/utilities/appendNonTrashedFilter.js.map +1 -0
  139. package/dist/utilities/getEntityPolicies.d.ts.map +1 -1
  140. package/dist/utilities/getEntityPolicies.js +2 -1
  141. package/dist/utilities/getEntityPolicies.js.map +1 -1
  142. package/package.json +2 -2
@@ -2,6 +2,7 @@ import type { I18nClient } from '@payloadcms/translations';
2
2
  import type { SanitizedCollectionConfig } from '../../collections/config/types.js';
3
3
  import type { ArrayFieldClient, BlocksFieldClient, CheckboxFieldClient, ClientField, CodeFieldClient, DateFieldClient, EmailFieldClient, Field, GroupFieldClient, JSONFieldClient, NumberFieldClient, PointFieldClient, RadioFieldClient, RelationshipFieldClient, SelectFieldClient, TextareaFieldClient, TextFieldClient, UploadFieldClient } from '../../fields/config/types.js';
4
4
  import type { Payload } from '../../types/index.js';
5
+ import type { ViewTypes } from '../types.js';
5
6
  export type RowData = Record<string, any>;
6
7
  export type DefaultCellComponentProps<TField extends ClientField = ClientField, TCellData = undefined> = {
7
8
  readonly cellData: TCellData extends undefined ? TField extends RelationshipFieldClient ? number | Record<string, any> | string : TField extends NumberFieldClient ? TField['hasMany'] extends true ? number[] : number : TField extends TextFieldClient ? TField['hasMany'] extends true ? string[] : string : TField extends CodeFieldClient | EmailFieldClient | JSONFieldClient | RadioFieldClient | TextareaFieldClient ? string : TField extends BlocksFieldClient ? {
@@ -23,6 +24,7 @@ export type DefaultCellComponentProps<TField extends ClientField = ClientField,
23
24
  rowData: RowData;
24
25
  }) => void;
25
26
  rowData: RowData;
27
+ viewType?: ViewTypes;
26
28
  };
27
29
  export type DefaultServerCellComponentProps<TField extends ClientField = ClientField, TCellData = any> = {
28
30
  collectionConfig: SanitizedCollectionConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"Cell.d.ts","sourceRoot":"","sources":["../../../src/admin/elements/Cell.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAA;AAClF,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf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ources":["../../../src/admin/elements/Cell.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\n\nimport type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type {\n ArrayFieldClient,\n BlocksFieldClient,\n CheckboxFieldClient,\n ClientField,\n CodeFieldClient,\n DateFieldClient,\n EmailFieldClient,\n Field,\n GroupFieldClient,\n JSONFieldClient,\n NumberFieldClient,\n PointFieldClient,\n RadioFieldClient,\n RelationshipFieldClient,\n SelectFieldClient,\n TextareaFieldClient,\n TextFieldClient,\n UploadFieldClient,\n} from '../../fields/config/types.js'\nimport type { Payload } from '../../types/index.js'\n\nexport type RowData = Record<string, any>\n\nexport type DefaultCellComponentProps<\n TField extends ClientField = ClientField,\n TCellData = undefined,\n> = {\n readonly cellData: TCellData extends undefined\n ? TField extends RelationshipFieldClient\n ? number | Record<string, any> | string\n : TField extends NumberFieldClient\n ? TField['hasMany'] extends true\n ? number[]\n : number\n : TField extends TextFieldClient\n ? TField['hasMany'] extends true\n ? string[]\n : string\n : TField extends\n | CodeFieldClient\n | EmailFieldClient\n | JSONFieldClient\n | RadioFieldClient\n | TextareaFieldClient\n ? string\n : TField extends BlocksFieldClient\n ? {\n [key: string]: any\n blockType: string\n }[]\n : TField extends CheckboxFieldClient\n ? boolean\n : TField extends DateFieldClient\n ? Date | number | string\n : TField extends GroupFieldClient\n ? Record<string, any>\n : TField extends UploadFieldClient\n ? File | string\n : TField extends ArrayFieldClient\n ? Record<string, unknown>[]\n : TField extends SelectFieldClient\n ? TField['hasMany'] extends true\n ? string[]\n : string\n : TField extends PointFieldClient\n ? { x: number; y: number }\n : any\n : TCellData\n className?: string\n collectionSlug: SanitizedCollectionConfig['slug']\n columnIndex?: number\n customCellProps?: Record<string, any>\n field: TField\n link?: boolean\n onClick?: (args: {\n cellData: unknown\n collectionSlug: SanitizedCollectionConfig['slug']\n rowData: RowData\n }) => void\n rowData: RowData\n}\n\nexport type DefaultServerCellComponentProps<\n TField extends ClientField = ClientField,\n TCellData = any,\n> = {\n collectionConfig: SanitizedCollectionConfig\n field: Field\n i18n: I18nClient\n payload: Payload\n} & Omit<DefaultCellComponentProps<TField, TCellData>, 'field'>\n"],"names":[],"mappings":"AAsFA,WAQ+D"}
1
+ {"version":3,"sources":["../../../src/admin/elements/Cell.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\n\nimport type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type {\n ArrayFieldClient,\n BlocksFieldClient,\n CheckboxFieldClient,\n ClientField,\n CodeFieldClient,\n DateFieldClient,\n EmailFieldClient,\n Field,\n GroupFieldClient,\n JSONFieldClient,\n NumberFieldClient,\n PointFieldClient,\n RadioFieldClient,\n RelationshipFieldClient,\n SelectFieldClient,\n TextareaFieldClient,\n TextFieldClient,\n UploadFieldClient,\n} from '../../fields/config/types.js'\nimport type { Payload } from '../../types/index.js'\nimport type { ViewTypes } from '../types.js'\n\nexport type RowData = Record<string, any>\n\nexport type DefaultCellComponentProps<\n TField extends ClientField = ClientField,\n TCellData = undefined,\n> = {\n readonly cellData: TCellData extends undefined\n ? TField extends RelationshipFieldClient\n ? number | Record<string, any> | string\n : TField extends NumberFieldClient\n ? TField['hasMany'] extends true\n ? number[]\n : number\n : TField extends TextFieldClient\n ? TField['hasMany'] extends true\n ? string[]\n : string\n : TField extends\n | CodeFieldClient\n | EmailFieldClient\n | JSONFieldClient\n | RadioFieldClient\n | TextareaFieldClient\n ? string\n : TField extends BlocksFieldClient\n ? {\n [key: string]: any\n blockType: string\n }[]\n : TField extends CheckboxFieldClient\n ? boolean\n : TField extends DateFieldClient\n ? Date | number | string\n : TField extends GroupFieldClient\n ? Record<string, any>\n : TField extends UploadFieldClient\n ? File | string\n : TField extends ArrayFieldClient\n ? Record<string, unknown>[]\n : TField extends SelectFieldClient\n ? TField['hasMany'] extends true\n ? string[]\n : string\n : TField extends PointFieldClient\n ? { x: number; y: number }\n : any\n : TCellData\n className?: string\n collectionSlug: SanitizedCollectionConfig['slug']\n columnIndex?: number\n customCellProps?: Record<string, any>\n field: TField\n link?: boolean\n onClick?: (args: {\n cellData: unknown\n collectionSlug: SanitizedCollectionConfig['slug']\n rowData: RowData\n }) => void\n rowData: RowData\n viewType?: ViewTypes\n}\n\nexport type DefaultServerCellComponentProps<\n TField extends ClientField = ClientField,\n TCellData = any,\n> = {\n collectionConfig: SanitizedCollectionConfig\n field: Field\n i18n: I18nClient\n payload: Payload\n} & Omit<DefaultCellComponentProps<TField, TCellData>, 'field'>\n"],"names":[],"mappings":"AAwFA,WAQ+D"}
@@ -101,6 +101,7 @@ export type BuildFormStateArgs = {
101
101
  */
102
102
  mockRSCs?: boolean;
103
103
  operation?: 'create' | 'update';
104
+ readOnly?: boolean;
104
105
  renderAllFields?: boolean;
105
106
  req: PayloadRequest;
106
107
  returnLockStatus?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/admin/forms/Form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAElE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAA;AACvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAE7E,MAAM,MAAM,IAAI,GAAG;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,GAAG,GAAG;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,gBAAgB,CAAC,EAAE;QACjB,QAAQ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AA2B,CAAA;CAC5C,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,cAAc,EAAE,4BAA4B,GAAG,SAAS,CAAA;IACxD,cAAc,EAAE,mBAAmB,CAAA;IACnC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,SAAS,CAAA;IAC7B,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IACpC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,gBAAgB,CAAC,EAAE,IAAI,CAAA;IACvB,qBAAqB,CAAC,EAAE,SAAS,CAAA;IAIjC,QAAQ,CAAC,EAAE,MAAM,kBAAkB,CAAA;IACnC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAIlB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,GAAG,EAAE,cAAc,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,GAAG,CACA;IACE,cAAc,EAAE,MAAM,CAAA;IAGtB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,GACD;IACE,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;CACnB,CACJ,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/admin/forms/Form.ts"],"sourcesContent":["import { type SupportedLanguages } from '@payloadcms/translations'\n\nimport type { SanitizedDocumentPermissions } from '../../auth/types.js'\nimport type { Field, Option, Validate } from '../../fields/config/types.js'\nimport type { TypedLocale } from '../../index.js'\nimport type { DocumentPreferences } from '../../preferences/types.js'\nimport type { PayloadRequest, SelectType, Where } from '../../types/index.js'\n\nexport type Data = {\n [key: string]: any\n}\n\nexport type Row = {\n blockType?: string\n collapsed?: boolean\n customComponents?: {\n RowLabel?: React.ReactNode\n }\n id: string\n isLoading?: boolean\n lastRenderedPath?: string\n}\n\nexport type FilterOptionsResult = {\n [relation: string]: boolean | Where\n}\n\nexport type FieldState = {\n /**\n * This is used to determine if the field was added by the server.\n * This ensures the field is not ignored by the client when merging form state.\n * This can happen because the current local state is treated as the source of truth.\n * See `mergeServerFormState` for more details.\n */\n addedByServer?: boolean\n customComponents?: {\n /**\n * This is used by UI fields, as they can have arbitrary components defined if used\n * as a vessel to bring in custom components.\n */\n [key: string]: React.ReactNode | React.ReactNode[] | undefined\n AfterInput?: React.ReactNode\n BeforeInput?: React.ReactNode\n Description?: React.ReactNode\n Error?: React.ReactNode\n Field?: React.ReactNode\n Label?: React.ReactNode\n }\n disableFormData?: boolean\n errorMessage?: string\n errorPaths?: string[]\n /**\n * The fieldSchema may be part of the form state if `includeSchema: true` is passed to buildFormState.\n * This will never be in the form state of the client.\n */\n fieldSchema?: Field\n filterOptions?: FilterOptionsResult\n initialValue?: unknown\n /**\n * The path of the field when its custom components were last rendered.\n * This is used to denote if a field has been rendered, and if so,\n * what path it was rendered under last.\n *\n * If this path is undefined, or, if it is different\n * from the current path of a given field, the field's components will be re-rendered.\n */\n lastRenderedPath?: string\n passesCondition?: boolean\n rows?: Row[]\n /**\n * The result of running `field.filterOptions` on select fields.\n */\n selectFilterOptions?: Option[]\n valid?: boolean\n validate?: Validate\n value?: unknown\n}\n\nexport type FieldStateWithoutComponents = Omit<FieldState, 'customComponents'>\n\nexport type FormState = {\n [path: string]: FieldState\n}\n\nexport type FormStateWithoutComponents = {\n [path: string]: FieldStateWithoutComponents\n}\n\nexport type BuildFormStateArgs = {\n data?: Data\n docPermissions: SanitizedDocumentPermissions | undefined\n docPreferences: DocumentPreferences\n /**\n * In case `formState` is not the top-level, document form state, this can be passed to\n * provide the top-level form state.\n */\n documentFormState?: FormState\n fallbackLocale?: false | TypedLocale\n formState?: FormState\n id?: number | string\n initialBlockData?: Data\n initialBlockFormState?: FormState\n /*\n If not i18n was passed, the language can be passed to init i18n\n */\n language?: keyof SupportedLanguages\n locale?: string\n /**\n * If true, will not render RSCs and instead return a simple string in their place.\n * This is useful for environments that lack RSC support, such as Jest.\n * Form state can still be built, but any server components will be omitted.\n * @default false\n */\n mockRSCs?: boolean\n operation?: 'create' | 'update'\n /*\n If true, will render field components within their state object\n */\n renderAllFields?: boolean\n req: PayloadRequest\n returnLockStatus?: boolean\n schemaPath: string\n select?: SelectType\n skipValidation?: boolean\n updateLastEdited?: boolean\n} & (\n | {\n collectionSlug: string\n // Do not type it as never. This still makes it so that either collectionSlug or globalSlug is required, but makes it easier to provide both collectionSlug and globalSlug if it's\n // unclear which one is actually available.\n globalSlug?: string\n }\n | {\n collectionSlug?: string\n globalSlug: string\n }\n)\n"],"names":[],"mappings":"AAwFA,WAgDC"}
1
+ {"version":3,"sources":["../../../src/admin/forms/Form.ts"],"sourcesContent":["import { type SupportedLanguages } from '@payloadcms/translations'\n\nimport type { SanitizedDocumentPermissions } from '../../auth/types.js'\nimport type { Field, Option, Validate } from '../../fields/config/types.js'\nimport type { TypedLocale } from '../../index.js'\nimport type { DocumentPreferences } from '../../preferences/types.js'\nimport type { PayloadRequest, SelectType, Where } from '../../types/index.js'\n\nexport type Data = {\n [key: string]: any\n}\n\nexport type Row = {\n blockType?: string\n collapsed?: boolean\n customComponents?: {\n RowLabel?: React.ReactNode\n }\n id: string\n isLoading?: boolean\n lastRenderedPath?: string\n}\n\nexport type FilterOptionsResult = {\n [relation: string]: boolean | Where\n}\n\nexport type FieldState = {\n /**\n * This is used to determine if the field was added by the server.\n * This ensures the field is not ignored by the client when merging form state.\n * This can happen because the current local state is treated as the source of truth.\n * See `mergeServerFormState` for more details.\n */\n addedByServer?: boolean\n customComponents?: {\n /**\n * This is used by UI fields, as they can have arbitrary components defined if used\n * as a vessel to bring in custom components.\n */\n [key: string]: React.ReactNode | React.ReactNode[] | undefined\n AfterInput?: React.ReactNode\n BeforeInput?: React.ReactNode\n Description?: React.ReactNode\n Error?: React.ReactNode\n Field?: React.ReactNode\n Label?: React.ReactNode\n }\n disableFormData?: boolean\n errorMessage?: string\n errorPaths?: string[]\n /**\n * The fieldSchema may be part of the form state if `includeSchema: true` is passed to buildFormState.\n * This will never be in the form state of the client.\n */\n fieldSchema?: Field\n filterOptions?: FilterOptionsResult\n initialValue?: unknown\n /**\n * The path of the field when its custom components were last rendered.\n * This is used to denote if a field has been rendered, and if so,\n * what path it was rendered under last.\n *\n * If this path is undefined, or, if it is different\n * from the current path of a given field, the field's components will be re-rendered.\n */\n lastRenderedPath?: string\n passesCondition?: boolean\n rows?: Row[]\n /**\n * The result of running `field.filterOptions` on select fields.\n */\n selectFilterOptions?: Option[]\n valid?: boolean\n validate?: Validate\n value?: unknown\n}\n\nexport type FieldStateWithoutComponents = Omit<FieldState, 'customComponents'>\n\nexport type FormState = {\n [path: string]: FieldState\n}\n\nexport type FormStateWithoutComponents = {\n [path: string]: FieldStateWithoutComponents\n}\n\nexport type BuildFormStateArgs = {\n data?: Data\n docPermissions: SanitizedDocumentPermissions | undefined\n docPreferences: DocumentPreferences\n /**\n * In case `formState` is not the top-level, document form state, this can be passed to\n * provide the top-level form state.\n */\n documentFormState?: FormState\n fallbackLocale?: false | TypedLocale\n formState?: FormState\n id?: number | string\n initialBlockData?: Data\n initialBlockFormState?: FormState\n /*\n If not i18n was passed, the language can be passed to init i18n\n */\n language?: keyof SupportedLanguages\n locale?: string\n /**\n * If true, will not render RSCs and instead return a simple string in their place.\n * This is useful for environments that lack RSC support, such as Jest.\n * Form state can still be built, but any server components will be omitted.\n * @default false\n */\n mockRSCs?: boolean\n operation?: 'create' | 'update'\n readOnly?: boolean\n /*\n If true, will render field components within their state object\n */\n renderAllFields?: boolean\n req: PayloadRequest\n returnLockStatus?: boolean\n schemaPath: string\n select?: SelectType\n skipValidation?: boolean\n updateLastEdited?: boolean\n} & (\n | {\n collectionSlug: string\n // Do not type it as never. This still makes it so that either collectionSlug or globalSlug is required, but makes it easier to provide both collectionSlug and globalSlug if it's\n // unclear which one is actually available.\n globalSlug?: string\n }\n | {\n collectionSlug?: string\n globalSlug: string\n }\n)\n"],"names":[],"mappings":"AAwFA,WAiDC"}
@@ -44,6 +44,7 @@ export type AdminViewServerPropsOnly = {
44
44
  readonly redirectAfterCreate?: boolean;
45
45
  readonly redirectAfterDelete?: boolean;
46
46
  readonly redirectAfterDuplicate?: boolean;
47
+ readonly redirectAfterRestore?: boolean;
47
48
  } & ServerProps;
48
49
  export type AdminViewServerProps = AdminViewClientProps & AdminViewServerPropsOnly;
49
50
  /**
@@ -70,7 +71,7 @@ export type InitPageResult = {
70
71
  /**
71
72
  * @todo This should be renamed to `ViewType` (singular)
72
73
  */
73
- export type ViewTypes = 'account' | 'collection-folders' | 'dashboard' | 'document' | 'folders' | 'list' | 'reset' | 'verify' | 'version';
74
+ export type ViewTypes = 'account' | 'collection-folders' | 'dashboard' | 'document' | 'folders' | 'list' | 'reset' | 'trash' | 'verify' | 'version';
74
75
  export type ServerPropsFromView = {
75
76
  collectionConfig?: SanitizedConfig['collections'][number];
76
77
  globalConfig?: SanitizedConfig['globals'][number];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/admin/views/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AAExE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAA;AACrE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAA;AAClF,OAAO,KAAK,EAAE,Y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AC,CAAC,MAAM,CAAC,CAAA;IACjD,WAAW,EAAE,eAAe,EAAE,CAAA;CAC/B,CAAA;AAGD,MAAM,MAAM,0BAA0B,GAAG;IACvC,cAAc,CAAC,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAA;IAClD,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG,EAAE,GAAG,WAAW,CAAA;AAE7D,MAAM,MAAM,0BAA0B,GAAG,0BAA0B,GAAG,8BAA8B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/admin/views/index.ts"],"sourcesContent":["import type { ClientTranslationsObject } from '@payloadcms/translations'\n\nimport type { SanitizedPermissions } from '../../auth/index.js'\nimport type { ImportMap } from '../../bin/generateImportMap/index.js'\nimport type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { ClientConfig } from '../../config/client.js'\nimport type {\n CustomComponent,\n Locale,\n MetaConfig,\n PayloadComponent,\n SanitizedConfig,\n ServerProps,\n} from '../../config/types.js'\nimport type { SanitizedGlobalConfig } from '../../globals/config/types.js'\nimport type { PayloadRequest } from '../../types/index.js'\nimport type { LanguageOptions } from '../LanguageOptions.js'\nimport type { Data, StaticDescription } from '../types.js'\nimport type { DocumentSubViewTypes } from './document.js'\n\nexport type AdminViewConfig = {\n Component: PayloadComponent\n /** Whether the path should be matched exactly or as a prefix */\n exact?: boolean\n meta?: MetaConfig\n /**\n * Any valid URL path or array of paths that [`path-to-regexp`](https://www.npmjs.com/package/path-to-regex) understands. Must begin with a forward slash (`/`).\n */\n path?: `/${string}`\n sensitive?: boolean\n strict?: boolean\n}\n\nexport type AdminViewClientProps = {\n browseByFolderSlugs?: SanitizedCollectionConfig['slug'][]\n clientConfig: ClientConfig\n documentSubViewType?: DocumentSubViewTypes\n viewType: ViewTypes\n}\n\nexport type AdminViewServerPropsOnly = {\n readonly clientConfig: ClientConfig\n readonly disableActions?: boolean\n /**\n * @todo remove `docID` here as it is already contained in `initPageResult`\n */\n readonly docID?: number | string\n readonly folderID?: number | string\n readonly importMap: ImportMap\n readonly initialData?: Data\n readonly initPageResult: InitPageResult\n readonly params?: { [key: string]: string | string[] | undefined }\n readonly redirectAfterCreate?: boolean\n readonly redirectAfterDelete?: boolean\n readonly redirectAfterDuplicate?: boolean\n} & ServerProps\n\nexport type AdminViewServerProps = AdminViewClientProps & AdminViewServerPropsOnly\n\n/**\n * @deprecated This should be removed in favor of direct props\n */\nexport type AdminViewComponent = PayloadComponent<AdminViewServerProps>\n\nexport type VisibleEntities = {\n collections: SanitizedCollectionConfig['slug'][]\n globals: SanitizedGlobalConfig['slug'][]\n}\n\nexport type InitPageResult = {\n collectionConfig?: SanitizedCollectionConfig\n cookies: Map<string, string>\n docID?: number | string\n globalConfig?: SanitizedGlobalConfig\n languageOptions: LanguageOptions\n locale?: Locale\n permissions: SanitizedPermissions\n redirectTo?: string\n req: PayloadRequest\n translations: ClientTranslationsObject\n visibleEntities: VisibleEntities\n}\n\n/**\n * @todo This should be renamed to `ViewType` (singular)\n */\nexport type ViewTypes =\n | 'account'\n | 'collection-folders'\n | 'dashboard'\n | 'document'\n | 'folders'\n | 'list'\n | 'reset'\n | 'verify'\n | 'version'\n\nexport type ServerPropsFromView = {\n collectionConfig?: SanitizedConfig['collections'][number]\n globalConfig?: SanitizedConfig['globals'][number]\n viewActions: CustomComponent[]\n}\n\n// Description\nexport type ViewDescriptionClientProps = {\n collectionSlug?: SanitizedCollectionConfig['slug']\n description: StaticDescription\n}\n\nexport type ViewDescriptionServerPropsOnly = {} & ServerProps\n\nexport type ViewDescriptionServerProps = ViewDescriptionClientProps & ViewDescriptionServerPropsOnly\n"],"names":[],"mappings":"AA+GA,WAAoG"}
1
+ {"version":3,"sources":["../../../src/admin/views/index.ts"],"sourcesContent":["import type { ClientTranslationsObject } from '@payloadcms/translations'\n\nimport type { SanitizedPermissions } from '../../auth/index.js'\nimport type { ImportMap } from '../../bin/generateImportMap/index.js'\nimport type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { ClientConfig } from '../../config/client.js'\nimport type {\n CustomComponent,\n Locale,\n MetaConfig,\n PayloadComponent,\n SanitizedConfig,\n ServerProps,\n} from '../../config/types.js'\nimport type { SanitizedGlobalConfig } from '../../globals/config/types.js'\nimport type { PayloadRequest } from '../../types/index.js'\nimport type { LanguageOptions } from '../LanguageOptions.js'\nimport type { Data, StaticDescription } from '../types.js'\nimport type { DocumentSubViewTypes } from './document.js'\n\nexport type AdminViewConfig = {\n Component: PayloadComponent\n /** Whether the path should be matched exactly or as a prefix */\n exact?: boolean\n meta?: MetaConfig\n /**\n * Any valid URL path or array of paths that [`path-to-regexp`](https://www.npmjs.com/package/path-to-regex) understands. Must begin with a forward slash (`/`).\n */\n path?: `/${string}`\n sensitive?: boolean\n strict?: boolean\n}\n\nexport type AdminViewClientProps = {\n browseByFolderSlugs?: SanitizedCollectionConfig['slug'][]\n clientConfig: ClientConfig\n documentSubViewType?: DocumentSubViewTypes\n viewType: ViewTypes\n}\n\nexport type AdminViewServerPropsOnly = {\n readonly clientConfig: ClientConfig\n readonly disableActions?: boolean\n /**\n * @todo remove `docID` here as it is already contained in `initPageResult`\n */\n readonly docID?: number | string\n readonly folderID?: number | string\n readonly importMap: ImportMap\n readonly initialData?: Data\n readonly initPageResult: InitPageResult\n readonly params?: { [key: string]: string | string[] | undefined }\n readonly redirectAfterCreate?: boolean\n readonly redirectAfterDelete?: boolean\n readonly redirectAfterDuplicate?: boolean\n readonly redirectAfterRestore?: boolean\n} & ServerProps\n\nexport type AdminViewServerProps = AdminViewClientProps & AdminViewServerPropsOnly\n\n/**\n * @deprecated This should be removed in favor of direct props\n */\nexport type AdminViewComponent = PayloadComponent<AdminViewServerProps>\n\nexport type VisibleEntities = {\n collections: SanitizedCollectionConfig['slug'][]\n globals: SanitizedGlobalConfig['slug'][]\n}\n\nexport type InitPageResult = {\n collectionConfig?: SanitizedCollectionConfig\n cookies: Map<string, string>\n docID?: number | string\n globalConfig?: SanitizedGlobalConfig\n languageOptions: LanguageOptions\n locale?: Locale\n permissions: SanitizedPermissions\n redirectTo?: string\n req: PayloadRequest\n translations: ClientTranslationsObject\n visibleEntities: VisibleEntities\n}\n\n/**\n * @todo This should be renamed to `ViewType` (singular)\n */\nexport type ViewTypes =\n | 'account'\n | 'collection-folders'\n | 'dashboard'\n | 'document'\n | 'folders'\n | 'list'\n | 'reset'\n | 'trash'\n | 'verify'\n | 'version'\n\nexport type ServerPropsFromView = {\n collectionConfig?: SanitizedConfig['collections'][number]\n globalConfig?: SanitizedConfig['globals'][number]\n viewActions: CustomComponent[]\n}\n\n// Description\nexport type ViewDescriptionClientProps = {\n collectionSlug?: SanitizedCollectionConfig['slug']\n description: StaticDescription\n}\n\nexport type ViewDescriptionServerPropsOnly = {} & ServerProps\n\nexport type ViewDescriptionServerProps = ViewDescriptionClientProps & ViewDescriptionServerPropsOnly\n"],"names":[],"mappings":"AAiHA,WAAoG"}
@@ -5,7 +5,7 @@ import type { CollectionPreferences } from '../../preferences/types.js';
5
5
  import type { QueryPreset } from '../../query-presets/types.js';
6
6
  import type { ResolvedFilterOptions } from '../../types/index.js';
7
7
  import type { Column } from '../elements/Table.js';
8
- import type { Data } from '../types.js';
8
+ import type { Data, ViewTypes } from '../types.js';
9
9
  export type ListViewSlots = {
10
10
  AfterList?: React.ReactNode;
11
11
  AfterListTable?: React.ReactNode;
@@ -38,6 +38,7 @@ export type ListViewClientProps = {
38
38
  disableQueryPresets?: boolean;
39
39
  enableRowSelections?: boolean;
40
40
  hasCreatePermission: boolean;
41
+ hasDeletePermission?: boolean;
41
42
  /**
42
43
  * @deprecated
43
44
  */
@@ -51,10 +52,12 @@ export type ListViewClientProps = {
51
52
  queryPresetPermissions?: SanitizedCollectionPermission;
52
53
  renderedFilters?: Map<string, React.ReactNode>;
53
54
  resolvedFilterOptions?: Map<string, ResolvedFilterOptions>;
55
+ viewType: ViewTypes;
54
56
  } & ListViewSlots;
55
57
  export type ListViewSlotSharedClientProps = {
56
58
  collectionSlug: SanitizedCollectionConfig['slug'];
57
59
  hasCreatePermission: boolean;
60
+ hasDeletePermission?: boolean;
58
61
  newDocumentURL: string;
59
62
  };
60
63
  export type BeforeListClientProps = ListViewSlotSharedClientProps;
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/admin/views/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,KAAK,EACV,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAEvC,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC3B,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAChC,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC5B,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACjC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC7B,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,CAAA;IACjC,KAAK,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAA;CAC3C,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,IAA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CAAA;IACtD,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;IAC9C,qBAAqB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAA;IAC1D,QAAQ,EAAE,SAAS,CAAA;CACpB,GAAG,aAAa,CAAA;AAEjB,MAAM,MAAM,6BAA6B,GAAG;IAC1C,cAAc,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAA;IACjD,mBAAmB,EAAE,OAAO,CAAA;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAGD,MAAM,MAAM,qBAAqB,GAAG,6BAA6B,CAAA;AACjE,MAAM,MAAM,yBAAyB,GAAG,EAAE,GAAG,uBAAuB,CAAA;AACpE,MAAM,MAAM,qBAAqB,GAAG,qBAAqB,GAAG,yBAAyB,CAAA;AAGrF,MAAM,MAAM,0BAA0B,GAAG,6BAA6B,CAAA;AACtE,MAAM,MAAM,8BAA8B,GAAG,EAAE,GAAG,uBAAuB,CAAA;AACzE,MAAM,MAAM,0BAA0B,GAAG,0BAA0B,GAAG,8BAA8B,CAAA;AAGpG,MAAM,MAAM,oBAAoB,GAAG,6BAA6B,CAAA;AAChE,MAAM,MAAM,wBAAwB,GAAG,EAAE,GAAG,uBAAuB,CAAA;AACnE,MAAM,MAAM,oBAAoB,GAAG,oBAAoB,GAAG,wBAAwB,CAAA;AAGlF,MAAM,MAAM,yBAAyB,GAAG,6BAA6B,CAAA;AACrE,MAAM,MAAM,6BAA6B,GAAG,EAAE,GAAG,uBAAuB,CAAA;AACxE,MAAM,MAAM,yBAAyB,GAAG,yBAAyB,GAAG,6BAA6B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/admin/views/list.ts"],"sourcesContent":["import type { SanitizedCollectionPermission } from '../../auth/types.js'\nimport type {\n CollectionAdminOptions,\n SanitizedCollectionConfig,\n} from '../../collections/config/types.js'\nimport type { ServerProps } from '../../config/types.js'\nimport type { CollectionPreferences } from '../../preferences/types.js'\nimport type { QueryPreset } from '../../query-presets/types.js'\nimport type { ResolvedFilterOptions } from '../../types/index.js'\nimport type { Column } from '../elements/Table.js'\nimport type { Data } from '../types.js'\n\nexport type ListViewSlots = {\n AfterList?: React.ReactNode\n AfterListTable?: React.ReactNode\n BeforeList?: React.ReactNode\n BeforeListTable?: React.ReactNode\n Description?: React.ReactNode\n listMenuItems?: React.ReactNode[]\n Table: React.ReactNode | React.ReactNode[]\n}\n\n/**\n * The `ListViewServerPropsOnly` approach is needed to ensure type strictness when injecting component props\n * There is no way to do something like `Omit<ListViewServerProps, keyof ListViewClientProps>`\n * This is because `ListViewClientProps` is a union which is impossible to exclude from\n * Exporting explicitly defined `ListViewServerPropsOnly`, etc. allows for the strictest typing\n */\nexport type ListViewServerPropsOnly = {\n collectionConfig: SanitizedCollectionConfig\n data: Data\n limit: number\n listPreferences: CollectionPreferences\n listSearchableFields: CollectionAdminOptions['listSearchableFields']\n} & ServerProps\n\nexport type ListViewServerProps = ListViewClientProps & ListViewServerPropsOnly\n\nexport type ListViewClientProps = {\n beforeActions?: React.ReactNode[]\n collectionSlug: SanitizedCollectionConfig['slug']\n columnState: Column[]\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n disableQueryPresets?: boolean\n enableRowSelections?: boolean\n hasCreatePermission: boolean\n /**\n * @deprecated\n */\n listPreferences?: CollectionPreferences\n newDocumentURL: string\n /**\n * @deprecated\n */\n preferenceKey?: string\n queryPreset?: QueryPreset\n queryPresetPermissions?: SanitizedCollectionPermission\n renderedFilters?: Map<string, React.ReactNode>\n resolvedFilterOptions?: Map<string, ResolvedFilterOptions>\n} & ListViewSlots\n\nexport type ListViewSlotSharedClientProps = {\n collectionSlug: SanitizedCollectionConfig['slug']\n hasCreatePermission: boolean\n newDocumentURL: string\n}\n\n// BeforeList\nexport type BeforeListClientProps = ListViewSlotSharedClientProps\nexport type BeforeListServerPropsOnly = {} & ListViewServerPropsOnly\nexport type BeforeListServerProps = BeforeListClientProps & BeforeListServerPropsOnly\n\n// BeforeListTable\nexport type BeforeListTableClientProps = ListViewSlotSharedClientProps\nexport type BeforeListTableServerPropsOnly = {} & ListViewServerPropsOnly\nexport type BeforeListTableServerProps = BeforeListTableClientProps & BeforeListTableServerPropsOnly\n\n// AfterList\nexport type AfterListClientProps = ListViewSlotSharedClientProps\nexport type AfterListServerPropsOnly = {} & ListViewServerPropsOnly\nexport type AfterListServerProps = AfterListClientProps & AfterListServerPropsOnly\n\n// AfterListTable\nexport type AfterListTableClientProps = ListViewSlotSharedClientProps\nexport type AfterListTableServerPropsOnly = {} & ListViewServerPropsOnly\nexport type AfterListTableServerProps = AfterListTableClientProps & AfterListTableServerPropsOnly\n"],"names":[],"mappings":"AAsFA,WAAiG"}
1
+ {"version":3,"sources":["../../../src/admin/views/list.ts"],"sourcesContent":["import type { SanitizedCollectionPermission } from '../../auth/types.js'\nimport type {\n CollectionAdminOptions,\n SanitizedCollectionConfig,\n} from '../../collections/config/types.js'\nimport type { ServerProps } from '../../config/types.js'\nimport type { CollectionPreferences } from '../../preferences/types.js'\nimport type { QueryPreset } from '../../query-presets/types.js'\nimport type { ResolvedFilterOptions } from '../../types/index.js'\nimport type { Column } from '../elements/Table.js'\nimport type { Data, ViewTypes } from '../types.js'\n\nexport type ListViewSlots = {\n AfterList?: React.ReactNode\n AfterListTable?: React.ReactNode\n BeforeList?: React.ReactNode\n BeforeListTable?: React.ReactNode\n Description?: React.ReactNode\n listMenuItems?: React.ReactNode[]\n Table: React.ReactNode | React.ReactNode[]\n}\n\n/**\n * The `ListViewServerPropsOnly` approach is needed to ensure type strictness when injecting component props\n * There is no way to do something like `Omit<ListViewServerProps, keyof ListViewClientProps>`\n * This is because `ListViewClientProps` is a union which is impossible to exclude from\n * Exporting explicitly defined `ListViewServerPropsOnly`, etc. allows for the strictest typing\n */\nexport type ListViewServerPropsOnly = {\n collectionConfig: SanitizedCollectionConfig\n data: Data\n limit: number\n listPreferences: CollectionPreferences\n listSearchableFields: CollectionAdminOptions['listSearchableFields']\n} & ServerProps\n\nexport type ListViewServerProps = ListViewClientProps & ListViewServerPropsOnly\n\nexport type ListViewClientProps = {\n beforeActions?: React.ReactNode[]\n collectionSlug: SanitizedCollectionConfig['slug']\n columnState: Column[]\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n disableQueryPresets?: boolean\n enableRowSelections?: boolean\n hasCreatePermission: boolean\n hasDeletePermission?: boolean\n /**\n * @deprecated\n */\n listPreferences?: CollectionPreferences\n newDocumentURL: string\n /**\n * @deprecated\n */\n preferenceKey?: string\n queryPreset?: QueryPreset\n queryPresetPermissions?: SanitizedCollectionPermission\n renderedFilters?: Map<string, React.ReactNode>\n resolvedFilterOptions?: Map<string, ResolvedFilterOptions>\n viewType: ViewTypes\n} & ListViewSlots\n\nexport type ListViewSlotSharedClientProps = {\n collectionSlug: SanitizedCollectionConfig['slug']\n hasCreatePermission: boolean\n hasDeletePermission?: boolean\n newDocumentURL: string\n}\n\n// BeforeList\nexport type BeforeListClientProps = ListViewSlotSharedClientProps\nexport type BeforeListServerPropsOnly = {} & ListViewServerPropsOnly\nexport type BeforeListServerProps = BeforeListClientProps & BeforeListServerPropsOnly\n\n// BeforeListTable\nexport type BeforeListTableClientProps = ListViewSlotSharedClientProps\nexport type BeforeListTableServerPropsOnly = {} & ListViewServerPropsOnly\nexport type BeforeListTableServerProps = BeforeListTableClientProps & BeforeListTableServerPropsOnly\n\n// AfterList\nexport type AfterListClientProps = ListViewSlotSharedClientProps\nexport type AfterListServerPropsOnly = {} & ListViewServerPropsOnly\nexport type AfterListServerProps = AfterListClientProps & AfterListServerPropsOnly\n\n// AfterListTable\nexport type AfterListTableClientProps = ListViewSlotSharedClientProps\nexport type AfterListTableServerPropsOnly = {} & ListViewServerPropsOnly\nexport type AfterListTableServerProps = AfterListTableClientProps & AfterListTableServerPropsOnly\n"],"names":[],"mappings":"AAyFA,WAAiG"}
@@ -1 +1 @@
1
- {"version":3,"file":"forgotPassword.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/forgotPassword.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gCAAgC,EAChC,UAAU,EACX,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAS,MAAM,sBAAsB,CAAA;AAWjE,MAAM,MAAM,SAAS,CAAC,KAAK,SAAS,cAAc,IAAI;IACpD,UAAU,EAAE,UAAU,CAAA;IACtB,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KACvB,GAAG,gCAAgC,CAAC,KAAK,CAAC,CAAC,gBAAgB,CAAC,CAAA;IAC7D,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,MAAM,CAAA;AAE3B,eAAO,MAAM,uBAAuB,GAAU,KAAK,SAAS,cAAc,gBAC1D,SAAS,CAAC,KAAK,CAAC,KAC7B,OAAO,CAAC,IAAI,GAAG,MAAM,CA8LvB,CAAA"}
1
+ {"version":3,"file":"forgotPassword.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/forgotPassword.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gCAAgC,EAChC,UAAU,EACX,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAS,MAAM,sBAAsB,CAAA;AAYjE,MAAM,MAAM,SAAS,CAAC,KAAK,SAAS,cAAc,IAAI;IACpD,UAAU,EAAE,UAAU,CAAA;IACtB,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KACvB,GAAG,gCAAgC,CAAC,KAAK,CAAC,CAAC,gBAAgB,CAAC,CAAA;IAC7D,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,MAAM,CAAA;AAE3B,eAAO,MAAM,uBAAuB,GAAU,KAAK,SAAS,cAAc,gBAC1D,SAAS,CAAC,KAAK,CAAC,KAC7B,OAAO,CAAC,IAAI,GAAG,MAAM,CAqMvB,CAAA"}
@@ -4,6 +4,7 @@ import { URL } from 'url';
4
4
  import { buildAfterOperation } from '../../collections/operations/utils.js';
5
5
  import { APIError } from '../../errors/index.js';
6
6
  import { Forbidden } from '../../index.js';
7
+ import { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js';
7
8
  import { commitTransaction } from '../../utilities/commitTransaction.js';
8
9
  import { formatAdminURL } from '../../utilities/formatAdminURL.js';
9
10
  import { initTransaction } from '../../utilities/initTransaction.js';
@@ -60,6 +61,12 @@ export const forgotPasswordOperation = async (incomingArgs)=>{
60
61
  }
61
62
  };
62
63
  }
64
+ // Exclude trashed users unless `trash: true`
65
+ whereConstraint = appendNonTrashedFilter({
66
+ enableTrash: collectionConfig.trash,
67
+ trash: false,
68
+ where: whereConstraint
69
+ });
63
70
  let user = await payload.db.findOne({
64
71
  collection: collectionConfig.slug,
65
72
  req,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/operations/forgotPassword.ts"],"sourcesContent":["import crypto from 'crypto'\nimport { status as httpStatus } from 'http-status'\nimport { URL } from 'url'\n\nimport type {\n AuthOperationsFromCollectionSlug,\n Collection,\n} from '../../collections/config/types.js'\nimport type { CollectionSlug } from '../../index.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\n\nimport { buildAfterOperation } from '../../collections/operations/utils.js'\nimport { APIError } from '../../errors/index.js'\nimport { Forbidden } from '../../index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { formatAdminURL } from '../../utilities/formatAdminURL.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { getLoginOptions } from '../getLoginOptions.js'\n\nexport type Arguments<TSlug extends CollectionSlug> = {\n collection: Collection\n data: {\n [key: string]: unknown\n } & AuthOperationsFromCollectionSlug<TSlug>['forgotPassword']\n disableEmail?: boolean\n expiration?: number\n req: PayloadRequest\n}\n\nexport type Result = string\n\nexport const forgotPasswordOperation = async <TSlug extends CollectionSlug>(\n incomingArgs: Arguments<TSlug>,\n): Promise<null | string> => {\n const loginWithUsername = incomingArgs.collection.config.auth.loginWithUsername\n const { data } = incomingArgs\n\n const { canLoginWithEmail, canLoginWithUsername } = getLoginOptions(loginWithUsername)\n\n const sanitizedEmail =\n (canLoginWithEmail && (incomingArgs.data.email || '').toLowerCase().trim()) || null\n const sanitizedUsername =\n 'username' in data && typeof data?.username === 'string'\n ? data.username.toLowerCase().trim()\n : null\n\n let args = incomingArgs\n\n if (incomingArgs.collection.config.auth.disableLocalStrategy) {\n throw new Forbidden(incomingArgs.req.t)\n }\n if (!sanitizedEmail && !sanitizedUsername) {\n throw new APIError(\n `Missing ${loginWithUsername ? 'username' : 'email'}.`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n try {\n const shouldCommit = await initTransaction(args.req)\n\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: 'forgotPassword',\n req: args.req,\n })) || args\n }\n }\n\n const {\n collection: { config: collectionConfig },\n disableEmail,\n expiration,\n req: {\n payload: { config, email },\n payload,\n },\n req,\n } = args\n\n // /////////////////////////////////////\n // Forget password\n // /////////////////////////////////////\n\n let token: string = crypto.randomBytes(20).toString('hex')\n type UserDoc = {\n email?: string\n id: number | string\n resetPasswordExpiration?: string\n resetPasswordToken?: string\n }\n\n if (!sanitizedEmail && !sanitizedUsername) {\n throw new APIError(\n `Missing ${loginWithUsername ? 'username' : 'email'}.`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n let whereConstraint: Where = {}\n\n if (canLoginWithEmail && sanitizedEmail) {\n whereConstraint = {\n email: {\n equals: sanitizedEmail,\n },\n }\n } else if (canLoginWithUsername && sanitizedUsername) {\n whereConstraint = {\n username: {\n equals: sanitizedUsername,\n },\n }\n }\n\n let user = await payload.db.findOne<UserDoc>({\n collection: collectionConfig.slug,\n req,\n where: whereConstraint,\n })\n\n // We don't want to indicate specifically that an email was not found,\n // as doing so could lead to the exposure of registered emails.\n // Therefore, we prefer to fail silently.\n if (!user) {\n await commitTransaction(args.req)\n return null\n }\n\n const resetPasswordExpiration = new Date(\n Date.now() + (collectionConfig.auth?.forgotPassword?.expiration ?? expiration ?? 3600000),\n ).toISOString()\n\n user = await payload.update({\n id: user.id,\n collection: collectionConfig.slug,\n data: {\n resetPasswordExpiration,\n resetPasswordToken: token,\n },\n req,\n })\n\n if (!disableEmail && user.email) {\n const protocol = new URL(req.url!).protocol // includes the final :\n const serverURL =\n config.serverURL !== null && config.serverURL !== ''\n ? config.serverURL\n : `${protocol}//${req.headers.get('host')}`\n const forgotURL = formatAdminURL({\n adminRoute: config.routes.admin,\n path: `${config.admin.routes.reset}/${token}`,\n serverURL,\n })\n let html = `${req.t('authentication:youAreReceivingResetPassword')}\n <a href=\"${forgotURL}\">${forgotURL}</a>\n ${req.t('authentication:youDidNotRequestPassword')}`\n\n if (typeof collectionConfig.auth.forgotPassword?.generateEmailHTML === 'function') {\n html = await collectionConfig.auth.forgotPassword.generateEmailHTML({\n req,\n token,\n user,\n })\n }\n\n let subject = req.t('authentication:resetYourPassword')\n\n if (typeof collectionConfig.auth.forgotPassword?.generateEmailSubject === 'function') {\n subject = await collectionConfig.auth.forgotPassword.generateEmailSubject({\n req,\n token,\n user,\n })\n }\n\n await email.sendEmail({\n from: `\"${email.defaultFromName}\" <${email.defaultFromAddress}>`,\n html,\n subject,\n to: user.email,\n })\n }\n\n // /////////////////////////////////////\n // afterForgotPassword - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterForgotPassword?.length) {\n for (const hook of collectionConfig.hooks.afterForgotPassword) {\n await hook({ args, collection: args.collection?.config, context: req.context })\n }\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n token = await buildAfterOperation({\n args,\n collection: args.collection?.config,\n operation: 'forgotPassword',\n result: token,\n })\n\n if (shouldCommit) {\n await commitTransaction(req)\n }\n\n return token\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["crypto","status","httpStatus","URL","buildAfterOperation","APIError","Forbidden","commitTransaction","formatAdminURL","initTransaction","killTransaction","getLoginOptions","forgotPasswordOperation","incomingArgs","loginWithUsername","collection","config","auth","data","canLoginWithEmail","canLoginWithUsername","sanitizedEmail","email","toLowerCase","trim","sanitizedUsername","username","args","disableLocalStrategy","req","t","BAD_REQUEST","shouldCommit","hooks","beforeOperation","length","hook","context","operation","collectionConfig","disableEmail","expiration","payload","token","randomBytes","toString","whereConstraint","equals","user","db","findOne","slug","where","resetPasswordExpiration","Date","now","forgotPassword","toISOString","update","id","resetPasswordToken","protocol","url","serverURL","headers","get","forgotURL","adminRoute","routes","admin","path","reset","html","generateEmailHTML","subject","generateEmailSubject","sendEmail","from","defaultFromName","defaultFromAddress","to","afterForgotPassword","result","error"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAC3B,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAClD,SAASC,GAAG,QAAQ,MAAK;AASzB,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,cAAc,QAAQ,oCAAmC;AACl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AAK1B,KAAK;YAChB;QACF;QAEA,wCAAwC;QACxC,mCAAmC;QACnC,wCAAwC;QAExC,IAAIiB,iBAAiBN,KAAK,EAAEgD,qBAAqB9C,QAAQ;YACvD,KAAK,MAAMC,QAAQG,iBAAiBN,KAAK,CAACgD,mBAAmB,CAAE;gBAC7D,MAAM7C,KAAK;oBAAET;oBAAMZ,YAAYY,KAAKZ,UAAU,EAAEC;oBAAQqB,SAASR,IAAIQ,OAAO;gBAAC;YAC/E;QACF;QAEA,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCM,QAAQ,MAAMvC,oBAAoB;YAChCuB;YACAZ,YAAYY,KAAKZ,UAAU,EAAEC;YAC7BsB,WAAW;YACX4C,QAAQvC;QACV;QAEA,IAAIX,cAAc;YAChB,MAAMzB,kBAAkBsB;QAC1B;QAEA,OAAOc;IACT,EAAE,OAAOwC,OAAgB;QACvB,MAAMzE,gBAAgBiB,KAAKE,GAAG;QAC9B,MAAMsD;IACR;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/operations/forgotPassword.ts"],"sourcesContent":["import crypto from 'crypto'\nimport { status as httpStatus } from 'http-status'\nimport { URL } from 'url'\n\nimport type {\n AuthOperationsFromCollectionSlug,\n Collection,\n} from '../../collections/config/types.js'\nimport type { CollectionSlug } from '../../index.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\n\nimport { buildAfterOperation } from '../../collections/operations/utils.js'\nimport { APIError } from '../../errors/index.js'\nimport { Forbidden } from '../../index.js'\nimport { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { formatAdminURL } from '../../utilities/formatAdminURL.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { getLoginOptions } from '../getLoginOptions.js'\n\nexport type Arguments<TSlug extends CollectionSlug> = {\n collection: Collection\n data: {\n [key: string]: unknown\n } & AuthOperationsFromCollectionSlug<TSlug>['forgotPassword']\n disableEmail?: boolean\n expiration?: number\n req: PayloadRequest\n}\n\nexport type Result = string\n\nexport const forgotPasswordOperation = async <TSlug extends CollectionSlug>(\n incomingArgs: Arguments<TSlug>,\n): Promise<null | string> => {\n const loginWithUsername = incomingArgs.collection.config.auth.loginWithUsername\n const { data } = incomingArgs\n\n const { canLoginWithEmail, canLoginWithUsername } = getLoginOptions(loginWithUsername)\n\n const sanitizedEmail =\n (canLoginWithEmail && (incomingArgs.data.email || '').toLowerCase().trim()) || null\n const sanitizedUsername =\n 'username' in data && typeof data?.username === 'string'\n ? data.username.toLowerCase().trim()\n : null\n\n let args = incomingArgs\n\n if (incomingArgs.collection.config.auth.disableLocalStrategy) {\n throw new Forbidden(incomingArgs.req.t)\n }\n if (!sanitizedEmail && !sanitizedUsername) {\n throw new APIError(\n `Missing ${loginWithUsername ? 'username' : 'email'}.`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n try {\n const shouldCommit = await initTransaction(args.req)\n\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: 'forgotPassword',\n req: args.req,\n })) || args\n }\n }\n\n const {\n collection: { config: collectionConfig },\n disableEmail,\n expiration,\n req: {\n payload: { config, email },\n payload,\n },\n req,\n } = args\n\n // /////////////////////////////////////\n // Forget password\n // /////////////////////////////////////\n\n let token: string = crypto.randomBytes(20).toString('hex')\n type UserDoc = {\n email?: string\n id: number | string\n resetPasswordExpiration?: string\n resetPasswordToken?: string\n }\n\n if (!sanitizedEmail && !sanitizedUsername) {\n throw new APIError(\n `Missing ${loginWithUsername ? 'username' : 'email'}.`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n let whereConstraint: Where = {}\n\n if (canLoginWithEmail && sanitizedEmail) {\n whereConstraint = {\n email: {\n equals: sanitizedEmail,\n },\n }\n } else if (canLoginWithUsername && sanitizedUsername) {\n whereConstraint = {\n username: {\n equals: sanitizedUsername,\n },\n }\n }\n\n // Exclude trashed users unless `trash: true`\n whereConstraint = appendNonTrashedFilter({\n enableTrash: collectionConfig.trash,\n trash: false,\n where: whereConstraint,\n })\n\n let user = await payload.db.findOne<UserDoc>({\n collection: collectionConfig.slug,\n req,\n where: whereConstraint,\n })\n\n // We don't want to indicate specifically that an email was not found,\n // as doing so could lead to the exposure of registered emails.\n // Therefore, we prefer to fail silently.\n if (!user) {\n await commitTransaction(args.req)\n return null\n }\n\n const resetPasswordExpiration = new Date(\n Date.now() + (collectionConfig.auth?.forgotPassword?.expiration ?? expiration ?? 3600000),\n ).toISOString()\n\n user = await payload.update({\n id: user.id,\n collection: collectionConfig.slug,\n data: {\n resetPasswordExpiration,\n resetPasswordToken: token,\n },\n req,\n })\n\n if (!disableEmail && user.email) {\n const protocol = new URL(req.url!).protocol // includes the final :\n const serverURL =\n config.serverURL !== null && config.serverURL !== ''\n ? config.serverURL\n : `${protocol}//${req.headers.get('host')}`\n const forgotURL = formatAdminURL({\n adminRoute: config.routes.admin,\n path: `${config.admin.routes.reset}/${token}`,\n serverURL,\n })\n let html = `${req.t('authentication:youAreReceivingResetPassword')}\n <a href=\"${forgotURL}\">${forgotURL}</a>\n ${req.t('authentication:youDidNotRequestPassword')}`\n\n if (typeof collectionConfig.auth.forgotPassword?.generateEmailHTML === 'function') {\n html = await collectionConfig.auth.forgotPassword.generateEmailHTML({\n req,\n token,\n user,\n })\n }\n\n let subject = req.t('authentication:resetYourPassword')\n\n if (typeof collectionConfig.auth.forgotPassword?.generateEmailSubject === 'function') {\n subject = await collectionConfig.auth.forgotPassword.generateEmailSubject({\n req,\n token,\n user,\n })\n }\n\n await email.sendEmail({\n from: `\"${email.defaultFromName}\" <${email.defaultFromAddress}>`,\n html,\n subject,\n to: user.email,\n })\n }\n\n // /////////////////////////////////////\n // afterForgotPassword - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterForgotPassword?.length) {\n for (const hook of collectionConfig.hooks.afterForgotPassword) {\n await hook({ args, collection: args.collection?.config, context: req.context })\n }\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n token = await buildAfterOperation({\n args,\n collection: args.collection?.config,\n operation: 'forgotPassword',\n result: token,\n })\n\n if (shouldCommit) {\n await commitTransaction(req)\n }\n\n return token\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["crypto","status","httpStatus","URL","buildAfterOperation","APIError","Forbidden","appendNonTrashedFilter","commitTransaction","formatAdminURL","initTransaction","killTransaction","getLoginOptions","forgotPasswordOperation","incomingArgs","loginWithUsername","collection","config","auth","data","canLoginWithEmail","canLoginWithUsername","sanitizedEmail","email","toLowerCase","trim","sanitizedUsername","username","args","disableLocalStrategy","req","t","BAD_REQUEST","shouldCommit","hooks","beforeOperation","length","hook","context","operation","collectionConfig","disableEmail","expiration","payload","token","randomBytes","toString","whereConstraint","equals","enableTrash","trash","where","user","db","findOne","slug","resetPasswordExpiration","Date","now","forgotPassword","toISOString","update","id","resetPasswordToken","protocol","url","serverURL","headers","get","forgotURL","adminRoute","routes","admin","path","reset","html","generateEmailHTML","subject","generateEmailSubject","sendEmail","from","defaultFromName","defaultFromAddress","to","afterForgotPassword","result","error"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAC3B,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAClD,SAASC,GAAG,QAAQ,MAAK;AASzB,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,cAAc,QAAQ,oCAAmC;AAClE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,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AC,CAAC;gBAChEP;gBACAE;gBACAM,IAAI/B,KAAK7B,KAAK;YAChB;QACF;QAEA,wCAAwC;QACxC,mCAAmC;QACnC,wCAAwC;QAExC,IAAIiB,iBAAiBN,KAAK,EAAEkD,qBAAqBhD,QAAQ;YACvD,KAAK,MAAMC,QAAQG,iBAAiBN,KAAK,CAACkD,mBAAmB,CAAE;gBAC7D,MAAM/C,KAAK;oBAAET;oBAAMZ,YAAYY,KAAKZ,UAAU,EAAEC;oBAAQqB,SAASR,IAAIQ,OAAO;gBAAC;YAC/E;QACF;QAEA,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCM,QAAQ,MAAMxC,oBAAoB;YAChCwB;YACAZ,YAAYY,KAAKZ,UAAU,EAAEC;YAC7BsB,WAAW;YACX8C,QAAQzC;QACV;QAEA,IAAIX,cAAc;YAChB,MAAMzB,kBAAkBsB;QAC1B;QAEA,OAAOc;IACT,EAAE,OAAO0C,OAAgB;QACvB,MAAM3E,gBAAgBiB,KAAKE,GAAG;QAC9B,MAAMwD;IACR;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D,eAAO,MAAM,aAAa,SAAgB;IACxC,UAAU,EAAE,MAAM,CAAA;IAClB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,OAAO,CAAC,OAAO,CASlB,CAAA"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAS,MAAM,sBAAsB,CAAA;AAIjE,eAAO,MAAM,aAAa,SAAgB;IACxC,UAAU,EAAE,MAAM,CAAA;IAClB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,OAAO,CAAC,OAAO,CAmBlB,CAAA"}
@@ -1,8 +1,17 @@
1
+ import { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js';
1
2
  export const initOperation = async (args)=>{
2
3
  const { collection: slug, req } = args;
4
+ const collectionConfig = req.payload.config.collections?.find((c)=>c.slug === slug);
5
+ // Exclude trashed documents unless `trash: true`
6
+ const where = appendNonTrashedFilter({
7
+ enableTrash: Boolean(collectionConfig?.trash),
8
+ trash: false,
9
+ where: {}
10
+ });
3
11
  const doc = await req.payload.db.findOne({
4
12
  collection: slug,
5
- req
13
+ req,
14
+ where
6
15
  });
7
16
  return !!doc;
8
17
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/operations/init.ts"],"sourcesContent":["import type { PayloadRequest } from '../../types/index.js'\n\nexport const initOperation = async (args: {\n collection: string\n req: PayloadRequest\n}): Promise<boolean> => {\n const { collection: slug, req } = args\n\n const doc = await req.payload.db.findOne({\n collection: slug,\n req,\n })\n\n return !!doc\n}\n"],"names":["initOperation","args","collection","slug","req","doc","payload","db","findOne"],"mappings":"AAEA,OAAO,MAAMA,gBAAgB,OAAOC;IAIlC,MAAM,EAAEC,YAAYC,IAAI,EAAEC,GAAG,EAAE,GAAGH;IAElC,MAAMI,MAAM,MAAMD,IAAIE,OAAO,CAACC,EAAE,CAACC,OAAO,CAAC;QACvCN,YAAYC;QACZC;IACF;IAEA,OAAO,CAAC,CAACC;AACX,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/operations/init.ts"],"sourcesContent":["import type { PayloadRequest, Where } from '../../types/index.js'\n\nimport { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js'\n\nexport const initOperation = async (args: {\n collection: string\n req: PayloadRequest\n}): Promise<boolean> => {\n const { collection: slug, req } = args\n\n const collectionConfig = req.payload.config.collections?.find((c) => c.slug === slug)\n\n // Exclude trashed documents unless `trash: true`\n const where: Where = appendNonTrashedFilter({\n enableTrash: Boolean(collectionConfig?.trash),\n trash: false,\n where: {},\n })\n\n const doc = await req.payload.db.findOne({\n collection: slug,\n req,\n where,\n })\n\n return !!doc\n}\n"],"names":["appendNonTrashedFilter","initOperation","args","collection","slug","req","collectionConfig","payload","config","collections","find","c","where","enableTrash","Boolean","trash","doc","db","findOne"],"mappings":"AAEA,SAASA,sBAAsB,QAAQ,4CAA2C;AAElF,OAAO,MAAMC,gBAAgB,OAAOC;IAIlC,MAAM,EAAEC,YAAYC,IAAI,EAAEC,GAAG,EAAE,GAAGH;IAElC,MAAMI,mBAAmBD,IAAIE,OAAO,CAACC,MAAM,CAACC,WAAW,EAAEC,KAAK,CAACC,IAAMA,EAAEP,IAAI,KAAKA;IAEhF,iDAAiD;IACjD,MAAMQ,QAAeZ,uBAAuB;QAC1Ca,aAAaC,QAAQR,kBAAkBS;QACvCA,OAAO;QACPH,OAAO,CAAC;IACV;IAEA,MAAMI,MAAM,MAAMX,IAAIE,OAAO,CAACU,EAAE,CAACC,OAAO,CAAC;QACvCf,YAAYC;QACZC;QACAO;IACF;IAEA,OAAO,CAAC,CAACI;AACX,EAAC"}
@@ -11,6 +11,7 @@ export type Options<TSlug extends CollectionSlug> = {
11
11
  overrideAccess?: boolean;
12
12
  req?: Partial<PayloadRequest>;
13
13
  showHiddenFields?: boolean;
14
+ trash?: boolean;
14
15
  };
15
16
  export declare function loginLocal<TSlug extends CollectionSlug>(payload: Payload, options: Options<TSlug>): Promise<{
16
17
  user: DataFromCollectionSlug<TSlug>;
@@ -1 +1 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../../src/auth/operations/local/login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gCAAgC,EAChC,cAAc,EACd,sBAAsB,EACtB,OAAO,EACP,cAAc,EACf,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAMzC,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,cAAc,IAAI;IAClD,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CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,wBAAsB,UAAU,CAAC,KAAK,SAAS,cAAc,EAC3D,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GACtB,OAAO,CAAC;IAAE,IAAI,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAA;CAAE,GAAG,MAAM,CAAC,CAiC3D"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/auth/operations/local/login.ts"],"sourcesContent":["import type {\n AuthOperationsFromCollectionSlug,\n CollectionSlug,\n DataFromCollectionSlug,\n Payload,\n RequestContext,\n} from '../../../index.js'\nimport type { PayloadRequest } from '../../../types/index.js'\nimport type { Result } from '../login.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { loginOperation } from '../login.js'\n\nexport type Options<TSlug extends CollectionSlug> = {\n collection: TSlug\n context?: RequestContext\n data: AuthOperationsFromCollectionSlug<TSlug>['login']\n depth?: number\n fallbackLocale?: string\n locale?: string\n overrideAccess?: boolean\n req?: Partial<PayloadRequest>\n showHiddenFields?: boolean\n}\n\nexport async function loginLocal<TSlug extends CollectionSlug>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<{ user: DataFromCollectionSlug<TSlug> } & Result> {\n const {\n collection: collectionSlug,\n data,\n depth,\n overrideAccess = true,\n showHiddenFields,\n } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Login Operation.`,\n )\n }\n\n const args = {\n collection,\n data,\n depth,\n overrideAccess,\n req: await createLocalReq(options, payload),\n showHiddenFields,\n }\n\n const result = await loginOperation<TSlug>(args)\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return result\n}\n"],"names":["APIError","createLocalReq","loginOperation","loginLocal","payload","options","collection","collectionSlug","data","depth","overrideAccess","showHiddenFields","collections","String","args","req","result","config","auth","removeTokenFromResponses","token"],"mappings":"AAUA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,cAAa;AAc5C,OAAO,eAAeC,WACpBC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EACJC,YAAYC,cAAc,EAC1BC,IAAI,EACJC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,gBAAgB,EACjB,GAAGN;IAEJ,MAAMC,aAAaF,QAAQQ,WAAW,CAACL,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEa,OAAON,gBAAgB,iCAAiC,CAAC;IAEzF;IAEA,MAAMO,OAAO;QACXR;QACAE;QACAC;QACAC;QACAK,KAAK,MAAMd,eAAeI,SAASD;QACnCO;IACF;IAEA,MAAMK,SAAS,MAAMd,eAAsBY;IAE3C,IAAIR,WAAWW,MAAM,CAACC,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOH,OAAOI,KAAK;IACrB;IAEA,OAAOJ;AACT"}
1
+ {"version":3,"sources":["../../../../src/auth/operations/local/login.ts"],"sourcesContent":["import type {\n AuthOperationsFromCollectionSlug,\n CollectionSlug,\n DataFromCollectionSlug,\n Payload,\n RequestContext,\n} from '../../../index.js'\nimport type { PayloadRequest } from '../../../types/index.js'\nimport type { Result } from '../login.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { loginOperation } from '../login.js'\n\nexport type Options<TSlug extends CollectionSlug> = {\n collection: TSlug\n context?: RequestContext\n data: AuthOperationsFromCollectionSlug<TSlug>['login']\n depth?: number\n fallbackLocale?: string\n locale?: string\n overrideAccess?: boolean\n req?: Partial<PayloadRequest>\n showHiddenFields?: boolean\n trash?: boolean\n}\n\nexport async function loginLocal<TSlug extends CollectionSlug>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<{ user: DataFromCollectionSlug<TSlug> } & Result> {\n const {\n collection: collectionSlug,\n data,\n depth,\n overrideAccess = true,\n showHiddenFields,\n } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Login Operation.`,\n )\n }\n\n const args = {\n collection,\n data,\n depth,\n overrideAccess,\n req: await createLocalReq(options, payload),\n showHiddenFields,\n }\n\n const result = await loginOperation<TSlug>(args)\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return result\n}\n"],"names":["APIError","createLocalReq","loginOperation","loginLocal","payload","options","collection","collectionSlug","data","depth","overrideAccess","showHiddenFields","collections","String","args","req","result","config","auth","removeTokenFromResponses","token"],"mappings":"AAUA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,cAAa;AAe5C,OAAO,eAAeC,WACpBC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EACJC,YAAYC,cAAc,EAC1BC,IAAI,EACJC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,gBAAgB,EACjB,GAAGN;IAEJ,MAAMC,aAAaF,QAAQQ,WAAW,CAACL,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEa,OAAON,gBAAgB,iCAAiC,CAAC;IAEzF;IAEA,MAAMO,OAAO;QACXR;QACAE;QACAC;QACAC;QACAK,KAAK,MAAMd,eAAeI,SAASD;QACnCO;IACF;IAEA,MAAMK,SAAS,MAAMd,eAAsBY;IAE3C,IAAIR,WAAWW,MAAM,CAACC,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOH,OAAOI,KAAK;IACrB;IAEA,OAAOJ;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gCAAgC,EAChC,UAAU,EACV,sBAAsB,EACvB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,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"}
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gCAAgC,EAChC,UAAU,EACV,sBAAsB,EACvB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAS,MAAM,sBAAsB,CAAA;AAuBjE,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,CAsU1D,CAAA"}
@@ -3,6 +3,7 @@ import { buildAfterOperation } from '../../collections/operations/utils.js';
3
3
  import { AuthenticationError, LockedAuth, UnverifiedEmail, ValidationError } from '../../errors/index.js';
4
4
  import { afterRead } from '../../fields/hooks/afterRead/index.js';
5
5
  import { Forbidden } from '../../index.js';
6
+ import { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js';
6
7
  import { killTransaction } from '../../utilities/killTransaction.js';
7
8
  import { sanitizeInternalFields } from '../../utilities/sanitizeInternalFields.js';
8
9
  import { getFieldsToSign } from '../getFieldsToSign.js';
@@ -142,6 +143,12 @@ export const loginOperation = async (incomingArgs)=>{
142
143
  } else if (canLoginWithUsername && sanitizedUsername) {
143
144
  whereConstraint = usernameConstraint;
144
145
  }
146
+ // Exclude trashed users
147
+ whereConstraint = appendNonTrashedFilter({
148
+ enableTrash: collectionConfig.trash,
149
+ trash: false,
150
+ where: whereConstraint
151
+ });
145
152
  let user = await payload.db.findOne({
146
153
  collection: collectionConfig.slug,
147
154
  req,
@@ -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 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;IAC5B;AACF,EAAC;AAED,OAAO,MAAMK,iBAAiB,OAC5BC;IAEA,IAAIC,OAAOD;IAEX,IAAIC,KAAKC,UAAU,CAACC,MAAM,CAACC,IAAI,CAACC,oBAAoB,EAAE;QACpD,MAAM,IAAI1B,UAAUsB,KAAKT,GAAG,CAACE,CAAC;IAChC;IAEA,IAAI;QACF,wCAAwC;QACxC,+BAA+B;QAC/B,wCAAwC;QAExC,IAAIO,KAAKC,UAAU,CAACC,MAAM,CAACG,KAAK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;YAC9C,KAAK,MAAMC,QAAQG,iBAAiBN,KAAK,CAACiE,UAAU,CAAE;gBACpD9E,OACE,AAAC,MAAMgB,KAAK;oBACVP,YAAYD,KAAKC,UAAU,EAAEC;oBAC7BO,SAAST,KAAKT,GAAG,CAACkB,OAAO;oBACzBlB,KAAKS,KAAKT,GAAG;oBACb8E;oBACA7E;gBACF,MAAOA;YACX;QACF;QAEA,wCAAwC;QACxC,qBAAqB;QACrB,wCAAwC;QAExCA,OAAO,MAAMf,UAAU;YACrBwB,YAAYU;YACZF,SAASlB,IAAIkB,OAAO;YACpBI,OAAOA;YACPiC,KAAKtD;YACL,oFAAoF;YACpF+E,OAAOC;YACPzD,gBAAgBA;YAChB0D,QAAQ;YACRzD,QAAQA;YACRF,gBAAgBA;YAChBvB;YACA4B,kBAAkBA;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 { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.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 // Exclude trashed users\n whereConstraint = appendNonTrashedFilter({\n enableTrash: collectionConfig.trash,\n trash: false,\n where: whereConstraint,\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","appendNonTrashedFilter","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","enableTrash","trash","where","db","findOne","_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,SA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EAAEC;oBAC7BO,SAAST,KAAKT,GAAG,CAACkB,OAAO;oBACzBlB,KAAKS,KAAKT,GAAG;oBACbgF;oBACA/E;gBACF,MAAOA;YACX;QACF;QAEA,wCAAwC;QACxC,qBAAqB;QACrB,wCAAwC;QAExCA,OAAO,MAAMhB,UAAU;YACrByB,YAAYU;YACZF,SAASlB,IAAIkB,OAAO;YACpBI,OAAOA;YACPmC,KAAKxD;YACL,oFAAoF;YACpFiF,OAAOC;YACP3D,gBAAgBA;YAChB4D,QAAQ;YACR3D,QAAQA;YACRF,gBAAgBA;YAChBvB;YACA4B,kBAAkBA;QACpB;QAEA,wCAAwC;QACxC,yBAAyB;QACzB,wCAAwC;QAExC,IAAIR,iBAAiBN,KAAK,EAAE7B,WAAW+B,QAAQ;YAC7C,KAAK,MAAMC,QAAQG,iBAAiBN,KAAK,CAAC7B,SAAS,CAAE;gBACnDgB,OACE,AAAC,MAAMgB,KAAK;oBACVP,YAAYD,KAAKC,UAAU,EAAEC;oBAC7BO,SAASlB,IAAIkB,OAAO;oBACpBuC,KAAKxD;oBACLD;gBACF,MAAOC;YACX;QACF;QAEA,IAAIoF,SAA2D;YAC7DN;YACAC;YACA/E;QACF;QAEA,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCoF,SAAS,MAAMzG,oBAAoB;YACjC6B;YACAC,YAAYD,KAAKC,UAAU,EAAEC;YAC7BQ,WAAW;YACXkE;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAOA;IACT,EAAE,OAAOC,OAAgB;QACvB,MAAMlG,gBAAgBqB,KAAKT,GAAG;QAC9B,MAAMsF;IACR;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/logout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAI1D,MAAM,MAAM,SAAS,GAAG;IACtB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,UAAU,EAAE,UAAU,CAAA;IACtB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,eAAe,iBAAwB,SAAS,KAAG,OAAO,CAAC,OAAO,CAgE9E,CAAA"}
1
+ {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/logout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAK1D,MAAM,MAAM,SAAS,GAAG;IACtB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,UAAU,EAAE,UAAU,CAAA;IACtB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,eAAe,iBAAwB,SAAS,KAAG,OAAO,CAAC,OAAO,CAsE9E,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { status as httpStatus } from 'http-status';
2
2
  import { APIError } from '../../errors/index.js';
3
+ import { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js';
3
4
  export const logoutOperation = async (incomingArgs)=>{
4
5
  let args = incomingArgs;
5
6
  const { allSessions, collection: { config: collectionConfig }, req: { user }, req } = incomingArgs;
@@ -19,15 +20,20 @@ export const logoutOperation = async (incomingArgs)=>{
19
20
  }
20
21
  }
21
22
  if (collectionConfig.auth.disableLocalStrategy !== true && collectionConfig.auth.useSessions) {
22
- const userWithSessions = await req.payload.db.findOne({
23
- collection: collectionConfig.slug,
24
- req,
23
+ const where = appendNonTrashedFilter({
24
+ enableTrash: Boolean(collectionConfig.trash),
25
+ trash: false,
25
26
  where: {
26
27
  id: {
27
28
  equals: user.id
28
29
  }
29
30
  }
30
31
  });
32
+ const userWithSessions = await req.payload.db.findOne({
33
+ collection: collectionConfig.slug,
34
+ req,
35
+ where
36
+ });
31
37
  if (!userWithSessions) {
32
38
  throw new APIError('No User', httpStatus.BAD_REQUEST);
33
39
  }