@payloadcms/next 3.0.0-alpha.61 → 3.0.0-alpha.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/withPayload.cjs +95 -0
- package/dist/cjs/withPayload.cjs.map +1 -0
- package/dist/exports/routes.d.ts +1 -1
- package/dist/exports/routes.d.ts.map +1 -1
- package/dist/exports/routes.js +1 -1
- package/dist/exports/routes.js.map +1 -1
- package/dist/exports/utilities.d.ts +4 -1
- package/dist/exports/utilities.d.ts.map +1 -1
- package/dist/exports/utilities.js +4 -1
- package/dist/exports/utilities.js.map +1 -1
- package/dist/layouts/Root/index.d.ts.map +1 -1
- package/dist/layouts/Root/index.js +23 -1
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/next-fileupload/handlers.js.map +1 -1
- package/dist/next-fileupload/isEligibleRequest.js +1 -1
- package/dist/next-fileupload/isEligibleRequest.js.map +1 -1
- package/dist/next-fileupload/processMultipart.d.ts.map +1 -1
- package/dist/next-fileupload/processMultipart.js +29 -6
- package/dist/next-fileupload/processMultipart.js.map +1 -1
- package/dist/next-fileupload/utilities.d.ts.map +1 -1
- package/dist/next-fileupload/utilities.js +4 -4
- package/dist/next-fileupload/utilities.js.map +1 -1
- package/dist/prod/styles.css +1 -1
- package/dist/routes/graphql/handler.d.ts.map +1 -1
- package/dist/routes/graphql/handler.js +8 -3
- package/dist/routes/graphql/handler.js.map +1 -1
- package/dist/routes/rest/auth/access.d.ts.map +1 -1
- package/dist/routes/rest/auth/access.js +5 -0
- package/dist/routes/rest/auth/access.js.map +1 -1
- package/dist/routes/rest/auth/forgotPassword.d.ts.map +1 -1
- package/dist/routes/rest/auth/forgotPassword.js +7 -2
- package/dist/routes/rest/auth/forgotPassword.js.map +1 -1
- package/dist/routes/rest/auth/init.d.ts.map +1 -1
- package/dist/routes/rest/auth/init.js +6 -0
- package/dist/routes/rest/auth/init.js.map +1 -1
- package/dist/routes/rest/auth/login.d.ts.map +1 -1
- package/dist/routes/rest/auth/login.js +8 -5
- package/dist/routes/rest/auth/login.js.map +1 -1
- package/dist/routes/rest/auth/logout.d.ts.map +1 -1
- package/dist/routes/rest/auth/logout.js +12 -7
- package/dist/routes/rest/auth/logout.js.map +1 -1
- package/dist/routes/rest/auth/me.d.ts.map +1 -1
- package/dist/routes/rest/auth/me.js +5 -0
- package/dist/routes/rest/auth/me.js.map +1 -1
- package/dist/routes/rest/auth/refresh.d.ts.map +1 -1
- package/dist/routes/rest/auth/refresh.js +11 -7
- package/dist/routes/rest/auth/refresh.js.map +1 -1
- package/dist/routes/rest/auth/registerFirstUser.d.ts.map +1 -1
- package/dist/routes/rest/auth/registerFirstUser.js +17 -5
- package/dist/routes/rest/auth/registerFirstUser.js.map +1 -1
- package/dist/routes/rest/auth/resetPassword.d.ts.map +1 -1
- package/dist/routes/rest/auth/resetPassword.js +8 -5
- package/dist/routes/rest/auth/resetPassword.js.map +1 -1
- package/dist/routes/rest/auth/unlock.d.ts.map +1 -1
- package/dist/routes/rest/auth/unlock.js +7 -2
- package/dist/routes/rest/auth/unlock.js.map +1 -1
- package/dist/routes/rest/auth/verifyEmail.d.ts.map +1 -1
- package/dist/routes/rest/auth/verifyEmail.js +7 -2
- package/dist/routes/rest/auth/verifyEmail.js.map +1 -1
- package/dist/routes/rest/buildFormState.d.ts.map +1 -1
- package/dist/routes/rest/buildFormState.js +16 -1
- package/dist/routes/rest/buildFormState.js.map +1 -1
- package/dist/routes/rest/collections/count.d.ts +3 -0
- package/dist/routes/rest/collections/count.d.ts.map +1 -0
- package/dist/routes/rest/collections/count.js +15 -0
- package/dist/routes/rest/collections/count.js.map +1 -0
- package/dist/routes/rest/collections/create.d.ts.map +1 -1
- package/dist/routes/rest/collections/create.js +5 -0
- package/dist/routes/rest/collections/create.js.map +1 -1
- package/dist/routes/rest/collections/delete.d.ts.map +1 -1
- package/dist/routes/rest/collections/delete.js +7 -0
- package/dist/routes/rest/collections/delete.js.map +1 -1
- package/dist/routes/rest/collections/deleteByID.d.ts.map +1 -1
- package/dist/routes/rest/collections/deleteByID.js +14 -1
- package/dist/routes/rest/collections/deleteByID.js.map +1 -1
- package/dist/routes/rest/collections/docAccess.d.ts.map +1 -1
- package/dist/routes/rest/collections/docAccess.js +5 -0
- package/dist/routes/rest/collections/docAccess.js.map +1 -1
- package/dist/routes/rest/collections/duplicate.d.ts.map +1 -1
- package/dist/routes/rest/collections/duplicate.js +12 -1
- package/dist/routes/rest/collections/duplicate.js.map +1 -1
- package/dist/routes/rest/collections/find.d.ts.map +1 -1
- package/dist/routes/rest/collections/find.js +5 -0
- package/dist/routes/rest/collections/find.js.map +1 -1
- package/dist/routes/rest/collections/findByID.d.ts.map +1 -1
- package/dist/routes/rest/collections/findByID.js +12 -1
- package/dist/routes/rest/collections/findByID.js.map +1 -1
- package/dist/routes/rest/collections/findVersionByID.d.ts.map +1 -1
- package/dist/routes/rest/collections/findVersionByID.js +12 -1
- package/dist/routes/rest/collections/findVersionByID.js.map +1 -1
- package/dist/routes/rest/collections/findVersions.d.ts.map +1 -1
- package/dist/routes/rest/collections/findVersions.js +5 -0
- package/dist/routes/rest/collections/findVersions.js.map +1 -1
- package/dist/routes/rest/collections/preview.d.ts.map +1 -1
- package/dist/routes/rest/collections/preview.js +11 -2
- package/dist/routes/rest/collections/preview.js.map +1 -1
- package/dist/routes/rest/collections/restoreVersion.d.ts.map +1 -1
- package/dist/routes/rest/collections/restoreVersion.js +12 -1
- package/dist/routes/rest/collections/restoreVersion.js.map +1 -1
- package/dist/routes/rest/collections/update.d.ts.map +1 -1
- package/dist/routes/rest/collections/update.js +7 -0
- package/dist/routes/rest/collections/update.js.map +1 -1
- package/dist/routes/rest/collections/updateByID.d.ts.map +1 -1
- package/dist/routes/rest/collections/updateByID.js +12 -1
- package/dist/routes/rest/collections/updateByID.js.map +1 -1
- package/dist/routes/rest/files/getFile.d.ts.map +1 -1
- package/dist/routes/rest/files/getFile.js +15 -8
- package/dist/routes/rest/files/getFile.js.map +1 -1
- package/dist/routes/rest/files/getFileTypeFallback.d.ts +7 -0
- package/dist/routes/rest/files/getFileTypeFallback.d.ts.map +1 -0
- package/dist/routes/rest/files/getFileTypeFallback.js +21 -0
- package/dist/routes/rest/files/getFileTypeFallback.js.map +1 -0
- package/dist/routes/rest/globals/docAccess.d.ts.map +1 -1
- package/dist/routes/rest/globals/docAccess.js +5 -0
- package/dist/routes/rest/globals/docAccess.js.map +1 -1
- package/dist/routes/rest/globals/findOne.d.ts.map +1 -1
- package/dist/routes/rest/globals/findOne.js +5 -0
- package/dist/routes/rest/globals/findOne.js.map +1 -1
- package/dist/routes/rest/globals/findVersionByID.d.ts.map +1 -1
- package/dist/routes/rest/globals/findVersionByID.js +5 -0
- package/dist/routes/rest/globals/findVersionByID.js.map +1 -1
- package/dist/routes/rest/globals/findVersions.d.ts.map +1 -1
- package/dist/routes/rest/globals/findVersions.js +5 -0
- package/dist/routes/rest/globals/findVersions.js.map +1 -1
- package/dist/routes/rest/globals/preview.d.ts.map +1 -1
- package/dist/routes/rest/globals/preview.js +11 -2
- package/dist/routes/rest/globals/preview.js.map +1 -1
- package/dist/routes/rest/globals/restoreVersion.d.ts.map +1 -1
- package/dist/routes/rest/globals/restoreVersion.js +5 -0
- package/dist/routes/rest/globals/restoreVersion.js.map +1 -1
- package/dist/routes/rest/globals/update.d.ts.map +1 -1
- package/dist/routes/rest/globals/update.js +5 -0
- package/dist/routes/rest/globals/update.js.map +1 -1
- package/dist/routes/rest/index.d.ts +1 -0
- package/dist/routes/rest/index.d.ts.map +1 -1
- package/dist/routes/rest/index.js +51 -5
- package/dist/routes/rest/index.js.map +1 -1
- package/dist/routes/rest/routeError.d.ts +4 -3
- package/dist/routes/rest/routeError.d.ts.map +1 -1
- package/dist/routes/rest/routeError.js +23 -9
- package/dist/routes/rest/routeError.js.map +1 -1
- package/dist/routes/rest/utilities/sanitizeCollectionID.d.ts +9 -0
- package/dist/routes/rest/utilities/sanitizeCollectionID.d.ts.map +1 -0
- package/dist/routes/rest/utilities/sanitizeCollectionID.js +13 -0
- package/dist/routes/rest/utilities/sanitizeCollectionID.js.map +1 -0
- package/dist/scss/app.scss +2 -3
- package/dist/scss/vars.scss +0 -7
- package/dist/utilities/getDataAndFile.d.ts.map +1 -1
- package/dist/utilities/getDataAndFile.js +26 -42
- package/dist/utilities/getDataAndFile.js.map +1 -1
- package/dist/utilities/getNextRequestI18n.d.ts +11 -0
- package/dist/utilities/getNextRequestI18n.d.ts.map +1 -0
- package/dist/utilities/getNextRequestI18n.js +18 -0
- package/dist/utilities/getNextRequestI18n.js.map +1 -0
- package/dist/utilities/getPayloadHMR.d.ts.map +1 -1
- package/dist/utilities/getPayloadHMR.js +2 -1
- package/dist/utilities/getPayloadHMR.js.map +1 -1
- package/dist/utilities/getRequestLanguage.d.ts.map +1 -1
- package/dist/utilities/getRequestLanguage.js +13 -5
- package/dist/utilities/getRequestLanguage.js.map +1 -1
- package/dist/utilities/headersWithCors.d.ts +8 -0
- package/dist/utilities/headersWithCors.d.ts.map +1 -0
- package/dist/utilities/headersWithCors.js +17 -0
- package/dist/utilities/headersWithCors.js.map +1 -0
- package/dist/utilities/initPage.d.ts.map +1 -1
- package/dist/utilities/initPage.js +15 -2
- package/dist/utilities/initPage.js.map +1 -1
- package/dist/views/API/index.client.js +2 -2
- package/dist/views/API/index.client.js.map +1 -1
- package/dist/views/CreateFirstUser/index.client.js +2 -2
- package/dist/views/CreateFirstUser/index.client.js.map +1 -1
- package/dist/views/CreateFirstUser/index.d.ts.map +1 -1
- package/dist/views/CreateFirstUser/index.js +27 -1
- package/dist/views/CreateFirstUser/index.js.map +1 -1
- package/dist/views/Document/getMetaBySegment.js +2 -2
- package/dist/views/Document/getMetaBySegment.js.map +1 -1
- package/dist/views/Edit/Default/{SetStepNav → SetDocumentStepNav}/index.d.ts +1 -1
- package/dist/views/Edit/Default/SetDocumentStepNav/index.d.ts.map +1 -0
- package/dist/views/Edit/Default/{SetStepNav → SetDocumentStepNav}/index.js +12 -5
- package/dist/views/Edit/Default/SetDocumentStepNav/index.js.map +1 -0
- package/dist/views/Edit/Default/index.d.ts.map +1 -1
- package/dist/views/Edit/Default/index.js +5 -4
- package/dist/views/Edit/Default/index.js.map +1 -1
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts +3 -0
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts.map +1 -0
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +55 -0
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -0
- package/dist/views/ForgotPassword/index.d.ts.map +1 -1
- package/dist/views/ForgotPassword/index.js +3 -39
- package/dist/views/ForgotPassword/index.js.map +1 -1
- package/dist/views/List/index.js +2 -2
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/LivePreview/Toolbar/Controls/index.d.ts.map +1 -1
- package/dist/views/LivePreview/Toolbar/Controls/index.js +6 -4
- package/dist/views/LivePreview/Toolbar/Controls/index.js.map +1 -1
- package/dist/views/LivePreview/index.client.js +2 -2
- package/dist/views/LivePreview/index.client.js.map +1 -1
- package/dist/views/Login/LoginForm/index.d.ts.map +1 -1
- package/dist/views/Login/LoginForm/index.js +26 -2
- package/dist/views/Login/LoginForm/index.js.map +1 -1
- package/dist/views/Logout/LogoutClient.d.ts.map +1 -1
- package/dist/views/Logout/LogoutClient.js +1 -2
- package/dist/views/Logout/LogoutClient.js.map +1 -1
- package/dist/views/NotFound/index.js +2 -2
- package/dist/views/NotFound/index.js.map +1 -1
- package/dist/views/Root/meta.js +2 -2
- package/dist/views/Root/meta.js.map +1 -1
- package/dist/views/Versions/index.js +3 -3
- package/dist/views/Versions/index.js.map +1 -1
- package/dist/withPayload.d.ts +1 -2
- package/dist/withPayload.d.ts.map +1 -1
- package/dist/withPayload.js +5 -1
- package/dist/withPayload.js.map +1 -1
- package/package.json +16 -13
- package/dist/prod/payload/SuisseIntl-Bold.woff +0 -0
- package/dist/prod/payload/SuisseIntl-Bold.woff2 +0 -0
- package/dist/prod/payload/SuisseIntl-Medium.woff +0 -0
- package/dist/prod/payload/SuisseIntl-Medium.woff2 +0 -0
- package/dist/prod/payload/SuisseIntl-SemiBold.woff +0 -0
- package/dist/prod/payload/SuisseIntl-SemiBold.woff2 +0 -0
- package/dist/prod/payload/SuisseIntl.woff +0 -0
- package/dist/prod/payload/SuisseIntl.woff2 +0 -0
- package/dist/prod/payload/merriweather-v30-latin-900.woff +0 -0
- package/dist/prod/payload/merriweather-v30-latin-900.woff2 +0 -0
- package/dist/prod/payload/merriweather-v30-latin-900italic.woff +0 -0
- package/dist/prod/payload/merriweather-v30-latin-900italic.woff2 +0 -0
- package/dist/prod/payload/merriweather-v30-latin-italic.woff +0 -0
- package/dist/prod/payload/merriweather-v30-latin-italic.woff2 +0 -0
- package/dist/prod/payload/merriweather-v30-latin-regular.woff +0 -0
- package/dist/prod/payload/merriweather-v30-latin-regular.woff2 +0 -0
- package/dist/scss/fonts.scss +0 -75
- package/dist/utilities/getNextI18n.d.ts +0 -7
- package/dist/utilities/getNextI18n.d.ts.map +0 -1
- package/dist/utilities/getNextI18n.js +0 -14
- package/dist/utilities/getNextI18n.js.map +0 -1
- package/dist/views/Edit/Default/SetStepNav/index.d.ts.map +0 -1
- package/dist/views/Edit/Default/SetStepNav/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/routes/graphql/handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAqC,eAAe,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/routes/graphql/handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAqC,eAAe,EAAE,MAAM,eAAe,CAAA;AAoDvF,eAAO,MAAM,UAAU,WAAkB,QAAQ,eAAe,CAAC,GAAG,eAAe,iBA0BlF,CAAA;AAED,eAAO,MAAM,IAAI,WACN,QAAQ,eAAe,CAAC,GAAG,eAAe,eAAqB,OAAO,sBAqD9E,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { configToSchema } from '@payloadcms/graphql';
|
|
|
2
2
|
import { createHandler } from 'graphql-http/lib/use/fetch';
|
|
3
3
|
import httpStatus from 'http-status';
|
|
4
4
|
import { createPayloadRequest } from '../../utilities/createPayloadRequest.js';
|
|
5
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
5
6
|
const handleError = async (payload, err, debug, afterErrorHook)=>{
|
|
6
7
|
const status = err.originalError.status || httpStatus.INTERNAL_SERVER_ERROR;
|
|
7
8
|
let errorMessage = err.message;
|
|
@@ -23,7 +24,7 @@ const handleError = async (payload, err, debug, afterErrorHook)=>{
|
|
|
23
24
|
path: err.path
|
|
24
25
|
};
|
|
25
26
|
if (afterErrorHook) {
|
|
26
|
-
({ response } =
|
|
27
|
+
({ response } = afterErrorHook(err, response, null, null) || {
|
|
27
28
|
response
|
|
28
29
|
});
|
|
29
30
|
}
|
|
@@ -48,6 +49,7 @@ export const getGraphql = async (config)=>{
|
|
|
48
49
|
return cached.graphql;
|
|
49
50
|
}
|
|
50
51
|
if (!cached.promise) {
|
|
52
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
51
53
|
cached.promise = new Promise(async (resolve)=>{
|
|
52
54
|
const resolvedConfig = await config;
|
|
53
55
|
const schema = await configToSchema(resolvedConfig);
|
|
@@ -98,12 +100,15 @@ export const POST = (config)=>async (request)=>{
|
|
|
98
100
|
schema,
|
|
99
101
|
validationRules: (request, args, defaultRules)=>defaultRules.concat(validationRules(args))
|
|
100
102
|
})(originalRequest);
|
|
101
|
-
const resHeaders =
|
|
103
|
+
const resHeaders = headersWithCors({
|
|
104
|
+
headers: new Headers(apiResponse.headers),
|
|
105
|
+
req
|
|
106
|
+
});
|
|
102
107
|
for(const key in headers){
|
|
103
108
|
resHeaders.append(key, headers[key]);
|
|
104
109
|
}
|
|
105
110
|
return new Response(apiResponse.body, {
|
|
106
|
-
headers:
|
|
111
|
+
headers: resHeaders,
|
|
107
112
|
status: apiResponse.status
|
|
108
113
|
});
|
|
109
114
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/routes/graphql/handler.ts"],"sourcesContent":["import type { GraphQLFormattedError } from 'graphql'\nimport type { GraphQLError } from 'graphql'\nimport type { CollectionAfterErrorHook, Payload, SanitizedConfig } from 'payload/types'\n\nimport { configToSchema } from '@payloadcms/graphql'\nimport { createHandler } from 'graphql-http/lib/use/fetch'\nimport httpStatus from 'http-status'\n\nimport { createPayloadRequest } from '../../utilities/createPayloadRequest.js'\n\nconst handleError = async (\n payload: Payload,\n err: any,\n debug: boolean,\n afterErrorHook: CollectionAfterErrorHook,\n): Promise<GraphQLFormattedError> => {\n const status = err.originalError.status || httpStatus.INTERNAL_SERVER_ERROR\n let errorMessage = err.message\n payload.logger.error(err.stack)\n\n // Internal server errors can contain anything, including potentially sensitive data.\n // Therefore, error details will be hidden from the response unless `config.debug` is `true`\n if (!debug && status === httpStatus.INTERNAL_SERVER_ERROR) {\n errorMessage = 'Something went wrong.'\n }\n\n let response: GraphQLFormattedError = {\n extensions: {\n name: err?.originalError?.name || undefined,\n data: (err && err.originalError && err.originalError.data) || undefined,\n stack: debug ? err.stack : undefined,\n statusCode: status,\n },\n locations: err.locations,\n message: errorMessage,\n path: err.path,\n }\n\n if (afterErrorHook) {\n ;({ response } =
|
|
1
|
+
{"version":3,"sources":["../../../src/routes/graphql/handler.ts"],"sourcesContent":["import type { GraphQLFormattedError } from 'graphql'\nimport type { GraphQLError } from 'graphql'\nimport type { CollectionAfterErrorHook, Payload, SanitizedConfig } from 'payload/types'\n\nimport { configToSchema } from '@payloadcms/graphql'\nimport { createHandler } from 'graphql-http/lib/use/fetch'\nimport httpStatus from 'http-status'\n\nimport { createPayloadRequest } from '../../utilities/createPayloadRequest.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\n\nconst handleError = async (\n payload: Payload,\n err: any,\n debug: boolean,\n afterErrorHook: CollectionAfterErrorHook,\n // eslint-disable-next-line @typescript-eslint/require-await\n): Promise<GraphQLFormattedError> => {\n const status = err.originalError.status || httpStatus.INTERNAL_SERVER_ERROR\n let errorMessage = err.message\n payload.logger.error(err.stack)\n\n // Internal server errors can contain anything, including potentially sensitive data.\n // Therefore, error details will be hidden from the response unless `config.debug` is `true`\n if (!debug && status === httpStatus.INTERNAL_SERVER_ERROR) {\n errorMessage = 'Something went wrong.'\n }\n\n let response: GraphQLFormattedError = {\n extensions: {\n name: err?.originalError?.name || undefined,\n data: (err && err.originalError && err.originalError.data) || undefined,\n stack: debug ? err.stack : undefined,\n statusCode: status,\n },\n locations: err.locations,\n message: errorMessage,\n path: err.path,\n }\n\n if (afterErrorHook) {\n ;({ response } = afterErrorHook(err, response, null, null) || { response })\n }\n\n return response\n}\n\nlet cached = global._payload_graphql\n\nif (!cached) {\n // eslint-disable-next-line no-multi-assign\n cached = global._payload_graphql = { graphql: null, promise: null }\n}\n\nexport const getGraphql = async (config: Promise<SanitizedConfig> | SanitizedConfig) => {\n if (process.env.NODE_ENV === 'development') {\n cached = global._payload_graphql = { graphql: null, promise: null }\n }\n\n if (cached.graphql) {\n return cached.graphql\n }\n\n if (!cached.promise) {\n // eslint-disable-next-line no-async-promise-executor\n cached.promise = new Promise(async (resolve) => {\n const resolvedConfig = await config\n const schema = await configToSchema(resolvedConfig)\n resolve(schema)\n })\n }\n\n try {\n cached.graphql = await cached.promise\n } catch (e) {\n cached.promise = null\n throw e\n }\n\n return cached.graphql\n}\n\nexport const POST =\n (config: Promise<SanitizedConfig> | SanitizedConfig) => async (request: Request) => {\n const originalRequest = request.clone()\n const req = await createPayloadRequest({\n config,\n request,\n })\n const { schema, validationRules } = await getGraphql(config)\n\n const { payload } = req\n\n const afterErrorHook =\n typeof payload.config.hooks.afterError === 'function' ? payload.config.hooks.afterError : null\n\n const headers = {}\n const apiResponse = await createHandler({\n context: { headers, req },\n onOperation: async (request, args, result) => {\n const response =\n typeof payload.extensions === 'function'\n ? await payload.extensions({\n args,\n req: request,\n result,\n })\n : result\n if (response.errors) {\n const errors = (await Promise.all(\n result.errors.map((error) => {\n return handleError(payload, error, payload.config.debug, afterErrorHook)\n }),\n )) as GraphQLError[]\n // errors type should be FormattedGraphQLError[] but onOperation has a return type of ExecutionResult instead of FormattedExecutionResult\n return { ...response, errors }\n }\n return response\n },\n schema,\n validationRules: (request, args, defaultRules) => defaultRules.concat(validationRules(args)),\n })(originalRequest)\n\n const resHeaders = headersWithCors({\n headers: new Headers(apiResponse.headers),\n req,\n })\n\n for (const key in headers) {\n resHeaders.append(key, headers[key])\n }\n\n return new Response(apiResponse.body, {\n headers: resHeaders,\n status: apiResponse.status,\n })\n }\n"],"names":["configToSchema","createHandler","httpStatus","createPayloadRequest","headersWithCors","handleError","payload","err","debug","afterErrorHook","status","originalError","INTERNAL_SERVER_ERROR","errorMessage","message","logger","error","stack","response","extensions","name","undefined","data","statusCode","locations","path","cached","global","_payload_graphql","graphql","promise","getGraphql","config","process","env","NODE_ENV","Promise","resolve","resolvedConfig","schema","e","POST","request","originalRequest","clone","req","validationRules","hooks","afterError","headers","apiResponse","context","onOperation","args","result","errors","all","map","defaultRules","concat","resHeaders","Headers","key","append","Response","body"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,cAAc,QAAQ,sBAAqB;AACpD,SAASC,aAAa,QAAQ,6BAA4B;AAC1D,OAAOC,gBAAgB,cAAa;AAEpC,SAASC,oBAAoB,QAAQ,0CAAyC;AAC9E,SAASC,eAAe,QAAQ,qCAAoC;AAEpE,MAAMC,cAAc,OAClBC,SACAC,KACAC,OACAC;IAGA,MAAMC,SAASH,IAAII,aAAa,CAACD,MAAM,IAAIR,WAAWU,qBAAqB;IAC3E,IAAIC,eAAeN,IAAIO,OAAO;IAC9BR,QAAQS,MAAM,CAACC,KAAK,CAACT,IAAIU,KAAK;IAE9B,qFAAqF;IACrF,4FAA4F;IAC5F,IAAI,CAACT,SAASE,WAAWR,WAAWU,qBAAqB,EAAE;QACzDC,eAAe;IACjB;IAEA,IAAIK,WAAkC;QACpCC,YAAY;YACVC,MAAMb,KAAKI,eAAeS,QAAQC;YAClCC,MAAM,AAACf,OAAOA,IAAII,aAAa,IAAIJ,IAAII,aAAa,CAACW,IAAI,IAAKD;YAC9DJ,OAAOT,QAAQD,IAAIU,KAAK,GAAGI;YAC3BE,YAAYb;QACd;QACAc,WAAWjB,IAAIiB,SAAS;QACxBV,SAASD;QACTY,MAAMlB,IAAIkB,IAAI;IAChB;IAEA,IAAIhB,gBAAgB;QAChB,CAAA,EAAES,QAAQ,EAAE,GAAGT,eAAeF,KAAKW,UAAU,MAAM,SAAS;YAAEA;QAAS,CAAA;IAC3E;IAEA,OAAOA;AACT;AAEA,IAAIQ,SAASC,OAAOC,gBAAgB;AAEpC,IAAI,CAACF,QAAQ;IACX,2CAA2C;IAC3CA,SAASC,OAAOC,gBAAgB,GAAG;QAAEC,SAAS;QAAMC,SAAS;IAAK;AACpE;AAEA,OAAO,MAAMC,aAAa,OAAOC;IAC/B,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1CT,SAASC,OAAOC,gBAAgB,GAAG;YAAEC,SAAS;YAAMC,SAAS;QAAK;IACpE;IAEA,IAAIJ,OAAOG,OAAO,EAAE;QAClB,OAAOH,OAAOG,OAAO;IACvB;IAEA,IAAI,CAACH,OAAOI,OAAO,EAAE;QACnB,qDAAqD;QACrDJ,OAAOI,OAAO,GAAG,IAAIM,QAAQ,OAAOC;YAClC,MAAMC,iBAAiB,MAAMN;YAC7B,MAAMO,SAAS,MAAMvC,eAAesC;YACpCD,QAAQE;QACV;IACF;IAEA,IAAI;QACFb,OAAOG,OAAO,GAAG,MAAMH,OAAOI,OAAO;IACvC,EAAE,OAAOU,GAAG;QACVd,OAAOI,OAAO,GAAG;QACjB,MAAMU;IACR;IAEA,OAAOd,OAAOG,OAAO;AACvB,EAAC;AAED,OAAO,MAAMY,OACX,CAACT,SAAuD,OAAOU;QAC7D,MAAMC,kBAAkBD,QAAQE,KAAK;QACrC,MAAMC,MAAM,MAAM1C,qBAAqB;YACrC6B;YACAU;QACF;QACA,MAAM,EAAEH,MAAM,EAAEO,eAAe,EAAE,GAAG,MAAMf,WAAWC;QAErD,MAAM,EAAE1B,OAAO,EAAE,GAAGuC;QAEpB,MAAMpC,iBACJ,OAAOH,QAAQ0B,MAAM,CAACe,KAAK,CAACC,UAAU,KAAK,aAAa1C,QAAQ0B,MAAM,CAACe,KAAK,CAACC,UAAU,GAAG;QAE5F,MAAMC,UAAU,CAAC;QACjB,MAAMC,cAAc,MAAMjD,cAAc;YACtCkD,SAAS;gBAAEF;gBAASJ;YAAI;YACxBO,aAAa,OAAOV,SAASW,MAAMC;gBACjC,MAAMpC,WACJ,OAAOZ,QAAQa,UAAU,KAAK,aAC1B,MAAMb,QAAQa,UAAU,CAAC;oBACvBkC;oBACAR,KAAKH;oBACLY;gBACF,KACAA;gBACN,IAAIpC,SAASqC,MAAM,EAAE;oBACnB,MAAMA,SAAU,MAAMnB,QAAQoB,GAAG,CAC/BF,OAAOC,MAAM,CAACE,GAAG,CAAC,CAACzC;wBACjB,OAAOX,YAAYC,SAASU,OAAOV,QAAQ0B,MAAM,CAACxB,KAAK,EAAEC;oBAC3D;oBAEF,yIAAyI;oBACzI,OAAO;wBAAE,GAAGS,QAAQ;wBAAEqC;oBAAO;gBAC/B;gBACA,OAAOrC;YACT;YACAqB;YACAO,iBAAiB,CAACJ,SAASW,MAAMK,eAAiBA,aAAaC,MAAM,CAACb,gBAAgBO;QACxF,GAAGV;QAEH,MAAMiB,aAAaxD,gBAAgB;YACjC6C,SAAS,IAAIY,QAAQX,YAAYD,OAAO;YACxCJ;QACF;QAEA,IAAK,MAAMiB,OAAOb,QAAS;YACzBW,WAAWG,MAAM,CAACD,KAAKb,OAAO,CAACa,IAAI;QACrC;QAEA,OAAO,IAAIE,SAASd,YAAYe,IAAI,EAAE;YACpChB,SAASW;YACTlD,QAAQwC,YAAYxC,MAAM;QAC5B;IACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/access.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/access.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAInD,eAAO,MAAM,MAAM,EAAE,gBAYpB,CAAA"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
2
|
import { accessOperation } from 'payload/operations';
|
|
3
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
3
4
|
export const access = async ({ req })=>{
|
|
4
5
|
const results = await accessOperation({
|
|
5
6
|
req
|
|
6
7
|
});
|
|
7
8
|
return Response.json(results, {
|
|
9
|
+
headers: headersWithCors({
|
|
10
|
+
headers: new Headers(),
|
|
11
|
+
req
|
|
12
|
+
}),
|
|
8
13
|
status: httpStatus.OK
|
|
9
14
|
});
|
|
10
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/access.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { accessOperation } from 'payload/operations'\n\nimport type { BaseRouteHandler } from '../types.js'\n\nexport const access: BaseRouteHandler = async ({ req }) => {\n const results = await accessOperation({\n req,\n })\n\n return Response.json(results, {\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","accessOperation","access","req","results","Response","json","status","OK"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/access.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { accessOperation } from 'payload/operations'\n\nimport type { BaseRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const access: BaseRouteHandler = async ({ req }) => {\n const results = await accessOperation({\n req,\n })\n\n return Response.json(results, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","accessOperation","headersWithCors","access","req","results","Response","json","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,qBAAoB;AAIpD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,SAA2B,OAAO,EAAEC,GAAG,EAAE;IACpD,MAAMC,UAAU,MAAMJ,gBAAgB;QACpCG;IACF;IAEA,OAAOE,SAASC,IAAI,CAACF,SAAS;QAC5BG,SAASN,gBAAgB;YACvBM,SAAS,IAAIC;YACbL;QACF;QACAM,QAAQV,WAAWW,EAAE;IACvB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forgotPassword.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/forgotPassword.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"forgotPassword.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/forgotPassword.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,cAAc,EAAE,sBAwB5B,CAAA"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
2
|
import { forgotPasswordOperation } from 'payload/operations';
|
|
3
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
3
4
|
export const forgotPassword = async ({ collection, req })=>{
|
|
5
|
+
const { t } = req;
|
|
4
6
|
await forgotPasswordOperation({
|
|
5
7
|
collection,
|
|
6
8
|
data: {
|
|
@@ -11,9 +13,12 @@ export const forgotPassword = async ({ collection, req })=>{
|
|
|
11
13
|
req
|
|
12
14
|
});
|
|
13
15
|
return Response.json({
|
|
14
|
-
|
|
15
|
-
message: 'Success'
|
|
16
|
+
message: t('general:success')
|
|
16
17
|
}, {
|
|
18
|
+
headers: headersWithCors({
|
|
19
|
+
headers: new Headers(),
|
|
20
|
+
req
|
|
21
|
+
}),
|
|
17
22
|
status: httpStatus.OK
|
|
18
23
|
});
|
|
19
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/forgotPassword.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { forgotPasswordOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const forgotPassword: CollectionRouteHandler = async ({ collection, req }) => {\n await forgotPasswordOperation({\n collection,\n data: {\n email: req.data.email as string,\n },\n disableEmail: Boolean(req.data?.disableEmail),\n expiration: typeof req.data.expiration === 'number' ? req.data.expiration : undefined,\n req,\n })\n\n return Response.json(\n {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/forgotPassword.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { forgotPasswordOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const forgotPassword: CollectionRouteHandler = async ({ collection, req }) => {\n const { t } = req\n await forgotPasswordOperation({\n collection,\n data: {\n email: req.data.email as string,\n },\n disableEmail: Boolean(req.data?.disableEmail),\n expiration: typeof req.data.expiration === 'number' ? req.data.expiration : undefined,\n req,\n })\n\n return Response.json(\n {\n message: t('general:success'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","forgotPasswordOperation","headersWithCors","forgotPassword","collection","req","t","data","email","disableEmail","Boolean","expiration","undefined","Response","json","message","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,uBAAuB,QAAQ,qBAAoB;AAI5D,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,iBAAyC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IAC9E,MAAM,EAAEC,CAAC,EAAE,GAAGD;IACd,MAAMJ,wBAAwB;QAC5BG;QACAG,MAAM;YACJC,OAAOH,IAAIE,IAAI,CAACC,KAAK;QACvB;QACAC,cAAcC,QAAQL,IAAIE,IAAI,EAAEE;QAChCE,YAAY,OAAON,IAAIE,IAAI,CAACI,UAAU,KAAK,WAAWN,IAAIE,IAAI,CAACI,UAAU,GAAGC;QAC5EP;IACF;IAEA,OAAOQ,SAASC,IAAI,CAClB;QACEC,SAAST,EAAE;IACb,GACA;QACEU,SAASd,gBAAgB;YACvBc,SAAS,IAAIC;YACbZ;QACF;QACAa,QAAQlB,WAAWmB,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,IAAI,EAAE,sBAelB,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { initOperation } from 'payload/operations';
|
|
2
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
2
3
|
export const init = async ({ collection, req })=>{
|
|
3
4
|
const initialized = await initOperation({
|
|
4
5
|
collection: collection.config.slug,
|
|
@@ -6,6 +7,11 @@ export const init = async ({ collection, req })=>{
|
|
|
6
7
|
});
|
|
7
8
|
return Response.json({
|
|
8
9
|
initialized
|
|
10
|
+
}, {
|
|
11
|
+
headers: headersWithCors({
|
|
12
|
+
headers: new Headers(),
|
|
13
|
+
req
|
|
14
|
+
})
|
|
9
15
|
});
|
|
10
16
|
};
|
|
11
17
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/init.ts"],"sourcesContent":["import { initOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const init: CollectionRouteHandler = async ({ collection, req }) => {\n const initialized = await initOperation({\n collection: collection.config.slug,\n req,\n })\n\n return Response.json({ initialized })\n}\n"],"names":["initOperation","init","collection","req","initialized","config","slug","Response","json"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/init.ts"],"sourcesContent":["import { initOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const init: CollectionRouteHandler = async ({ collection, req }) => {\n const initialized = await initOperation({\n collection: collection.config.slug,\n req,\n })\n\n return Response.json(\n { initialized },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n },\n )\n}\n"],"names":["initOperation","headersWithCors","init","collection","req","initialized","config","slug","Response","json","headers","Headers"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAoB;AAIlD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,OAA+B,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACpE,MAAMC,cAAc,MAAML,cAAc;QACtCG,YAAYA,WAAWG,MAAM,CAACC,IAAI;QAClCH;IACF;IAEA,OAAOI,SAASC,IAAI,CAClB;QAAEJ;IAAY,GACd;QACEK,SAAST,gBAAgB;YACvBS,SAAS,IAAIC;YACbP;QACF;IACF;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/login.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/login.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,KAAK,EAAE,sBAuCnB,CAAA"}
|
|
@@ -2,8 +2,9 @@ import httpStatus from 'http-status';
|
|
|
2
2
|
import { generatePayloadCookie } from 'payload/auth';
|
|
3
3
|
import { loginOperation } from 'payload/operations';
|
|
4
4
|
import { isNumber } from 'payload/utilities';
|
|
5
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
6
|
export const login = async ({ collection, req })=>{
|
|
6
|
-
const { searchParams } = req;
|
|
7
|
+
const { searchParams, t } = req;
|
|
7
8
|
const depth = searchParams.get('depth');
|
|
8
9
|
const result = await loginOperation({
|
|
9
10
|
collection,
|
|
@@ -23,12 +24,14 @@ export const login = async ({ collection, req })=>{
|
|
|
23
24
|
delete result.token;
|
|
24
25
|
}
|
|
25
26
|
return Response.json({
|
|
26
|
-
|
|
27
|
-
message: 'Auth Passed',
|
|
27
|
+
message: t('authentication:passed'),
|
|
28
28
|
...result
|
|
29
29
|
}, {
|
|
30
|
-
headers:
|
|
31
|
-
|
|
30
|
+
headers: headersWithCors({
|
|
31
|
+
headers: new Headers({
|
|
32
|
+
'Set-Cookie': cookie
|
|
33
|
+
}),
|
|
34
|
+
req
|
|
32
35
|
}),
|
|
33
36
|
status: httpStatus.OK
|
|
34
37
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/login.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie } from 'payload/auth'\nimport { loginOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const login: CollectionRouteHandler = async ({ collection, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const result = await loginOperation({\n collection,\n data: {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n },\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionConfig: collection.config,\n payload: req.payload,\n token: result.token,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/login.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie } from 'payload/auth'\nimport { loginOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const login: CollectionRouteHandler = async ({ collection, req }) => {\n const { searchParams, t } = req\n const depth = searchParams.get('depth')\n\n const result = await loginOperation({\n collection,\n data: {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n },\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionConfig: collection.config,\n payload: req.payload,\n token: result.token,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n message: t('authentication:passed'),\n ...result,\n },\n {\n headers: headersWithCors({\n headers: new Headers({\n 'Set-Cookie': cookie,\n }),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","generatePayloadCookie","loginOperation","isNumber","headersWithCors","login","collection","req","searchParams","t","depth","get","result","data","email","password","Number","undefined","cookie","collectionConfig","config","payload","token","auth","removeTokenFromResponses","Response","json","message","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,cAAc,QAAQ,qBAAoB;AACnD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,QAAgC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACrE,MAAM,EAAEC,YAAY,EAAEC,CAAC,EAAE,GAAGF;IAC5B,MAAMG,QAAQF,aAAaG,GAAG,CAAC;IAE/B,MAAMC,SAAS,MAAMV,eAAe;QAClCI;QACAO,MAAM;YACJC,OAAO,OAAOP,IAAIM,IAAI,EAAEC,UAAU,WAAWP,IAAIM,IAAI,CAACC,KAAK,GAAG;YAC9DC,UAAU,OAAOR,IAAIM,IAAI,EAAEE,aAAa,WAAWR,IAAIM,IAAI,CAACE,QAAQ,GAAG;QACzE;QACAL,OAAOP,SAASO,SAASM,OAAON,SAASO;QACzCV;IACF;IAEA,MAAMW,SAASjB,sBAAsB;QACnCkB,kBAAkBb,WAAWc,MAAM;QACnCC,SAASd,IAAIc,OAAO;QACpBC,OAAOV,OAAOU,KAAK;IACrB;IAEA,IAAIhB,WAAWc,MAAM,CAACG,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOZ,OAAOU,KAAK;IACrB;IAEA,OAAOG,SAASC,IAAI,CAClB;QACEC,SAASlB,EAAE;QACX,GAAGG,MAAM;IACX,GACA;QACEgB,SAASxB,gBAAgB;YACvBwB,SAAS,IAAIC,QAAQ;gBACnB,cAAcX;YAChB;YACAX;QACF;QACAuB,QAAQ9B,WAAW+B,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/logout.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/logout.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,MAAM,EAAE,sBAwCpB,CAAA"}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
2
|
import { generateExpiredPayloadCookie } from 'payload/auth';
|
|
3
3
|
import { logoutOperation } from 'payload/operations';
|
|
4
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
4
5
|
export const logout = async ({ collection, req })=>{
|
|
5
|
-
const
|
|
6
|
+
const { t } = req;
|
|
7
|
+
const result = await logoutOperation({
|
|
6
8
|
collection,
|
|
7
9
|
req
|
|
8
10
|
});
|
|
11
|
+
const headers = headersWithCors({
|
|
12
|
+
headers: new Headers(),
|
|
13
|
+
req
|
|
14
|
+
});
|
|
9
15
|
if (!result) {
|
|
10
16
|
return Response.json({
|
|
11
|
-
message: '
|
|
17
|
+
message: t('error:logoutFailed')
|
|
12
18
|
}, {
|
|
19
|
+
headers,
|
|
13
20
|
status: httpStatus.BAD_REQUEST
|
|
14
21
|
});
|
|
15
22
|
}
|
|
@@ -17,13 +24,11 @@ export const logout = async ({ collection, req })=>{
|
|
|
17
24
|
collectionConfig: collection.config,
|
|
18
25
|
payload: req.payload
|
|
19
26
|
});
|
|
27
|
+
headers.set('Set-Cookie', expiredCookie);
|
|
20
28
|
return Response.json({
|
|
21
|
-
|
|
22
|
-
message: 'Logout successful.'
|
|
29
|
+
message: t('authentication:logoutSuccessful')
|
|
23
30
|
}, {
|
|
24
|
-
headers
|
|
25
|
-
'Set-Cookie': expiredCookie
|
|
26
|
-
}),
|
|
31
|
+
headers,
|
|
27
32
|
status: httpStatus.OK
|
|
28
33
|
});
|
|
29
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/logout.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generateExpiredPayloadCookie } from 'payload/auth'\nimport { logoutOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const logout: CollectionRouteHandler = async ({ collection, req }) => {\n const result = logoutOperation({\n collection,\n req,\n })\n\n if (!result) {\n return Response.json(\n {\n message: '
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/logout.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generateExpiredPayloadCookie } from 'payload/auth'\nimport { logoutOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const logout: CollectionRouteHandler = async ({ collection, req }) => {\n const { t } = req\n const result = await logoutOperation({\n collection,\n req,\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (!result) {\n return Response.json(\n {\n message: t('error:logoutFailed'),\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n\n const expiredCookie = generateExpiredPayloadCookie({\n collectionConfig: collection.config,\n payload: req.payload,\n })\n\n headers.set('Set-Cookie', expiredCookie)\n\n return Response.json(\n {\n message: t('authentication:logoutSuccessful'),\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","generateExpiredPayloadCookie","logoutOperation","headersWithCors","logout","collection","req","t","result","headers","Headers","Response","json","message","status","BAD_REQUEST","expiredCookie","collectionConfig","config","payload","set","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,4BAA4B,QAAQ,eAAc;AAC3D,SAASC,eAAe,QAAQ,qBAAoB;AAIpD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,SAAiC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACtE,MAAM,EAAEC,CAAC,EAAE,GAAGD;IACd,MAAME,SAAS,MAAMN,gBAAgB;QACnCG;QACAC;IACF;IAEA,MAAMG,UAAUN,gBAAgB;QAC9BM,SAAS,IAAIC;QACbJ;IACF;IAEA,IAAI,CAACE,QAAQ;QACX,OAAOG,SAASC,IAAI,CAClB;YACEC,SAASN,EAAE;QACb,GACA;YACEE;YACAK,QAAQd,WAAWe,WAAW;QAChC;IAEJ;IAEA,MAAMC,gBAAgBf,6BAA6B;QACjDgB,kBAAkBZ,WAAWa,MAAM;QACnCC,SAASb,IAAIa,OAAO;IACtB;IAEAV,QAAQW,GAAG,CAAC,cAAcJ;IAE1B,OAAOL,SAASC,IAAI,CAClB;QACEC,SAASN,EAAE;IACb,GACA;QACEE;QACAK,QAAQd,WAAWqB,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/me.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/me.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,EAAE,EAAE,sBA0BhB,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
2
|
import { extractJWT } from 'payload/auth';
|
|
3
3
|
import { meOperation } from 'payload/operations';
|
|
4
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
4
5
|
export const me = async ({ collection, req })=>{
|
|
5
6
|
const currentToken = extractJWT(req);
|
|
6
7
|
const result = await meOperation({
|
|
@@ -15,6 +16,10 @@ export const me = async ({ collection, req })=>{
|
|
|
15
16
|
...result,
|
|
16
17
|
message: req.t('authentication:account')
|
|
17
18
|
}, {
|
|
19
|
+
headers: headersWithCors({
|
|
20
|
+
headers: new Headers(),
|
|
21
|
+
req
|
|
22
|
+
}),
|
|
18
23
|
status: httpStatus.OK
|
|
19
24
|
});
|
|
20
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/me.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { extractJWT } from 'payload/auth'\nimport { meOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const me: CollectionRouteHandler = async ({ collection, req }) => {\n const currentToken = extractJWT(req)\n\n const result = await meOperation({\n collection,\n currentToken,\n req,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n ...result,\n message: req.t('authentication:account'),\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","extractJWT","meOperation","me","collection","req","currentToken","result","config","auth","removeTokenFromResponses","token","Response","json","message","t","status","OK"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/me.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { extractJWT } from 'payload/auth'\nimport { meOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const me: CollectionRouteHandler = async ({ collection, req }) => {\n const currentToken = extractJWT(req)\n\n const result = await meOperation({\n collection,\n currentToken,\n req,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n ...result,\n message: req.t('authentication:account'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","extractJWT","meOperation","headersWithCors","me","collection","req","currentToken","result","config","auth","removeTokenFromResponses","token","Response","json","message","t","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,UAAU,QAAQ,eAAc;AACzC,SAASC,WAAW,QAAQ,qBAAoB;AAIhD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,KAA6B,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IAClE,MAAMC,eAAeN,WAAWK;IAEhC,MAAME,SAAS,MAAMN,YAAY;QAC/BG;QACAE;QACAD;IACF;IAEA,IAAID,WAAWI,MAAM,CAACC,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOH,OAAOI,KAAK;IACrB;IAEA,OAAOC,SAASC,IAAI,CAClB;QACE,GAAGN,MAAM;QACTO,SAAST,IAAIU,CAAC,CAAC;IACjB,GACA;QACEC,SAASd,gBAAgB;YACvBc,SAAS,IAAIC;YACbZ;QACF;QACAa,QAAQnB,WAAWoB,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/refresh.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/refresh.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,OAAO,EAAE,sBAiDrB,CAAA"}
|
|
@@ -2,13 +2,19 @@ import httpStatus from 'http-status';
|
|
|
2
2
|
import { extractJWT } from 'payload/auth';
|
|
3
3
|
import { generatePayloadCookie } from 'payload/auth';
|
|
4
4
|
import { refreshOperation } from 'payload/operations';
|
|
5
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
6
|
export const refresh = async ({ collection, req })=>{
|
|
7
|
+
const { t } = req;
|
|
6
8
|
const token = typeof req.data?.token === 'string' ? req.data.token : extractJWT(req);
|
|
9
|
+
const headers = headersWithCors({
|
|
10
|
+
headers: new Headers(),
|
|
11
|
+
req
|
|
12
|
+
});
|
|
7
13
|
if (!token) {
|
|
8
14
|
return Response.json({
|
|
9
|
-
|
|
10
|
-
message: 'Token not provided.'
|
|
15
|
+
message: t('error:tokenNotProvided')
|
|
11
16
|
}, {
|
|
17
|
+
headers,
|
|
12
18
|
status: httpStatus.UNAUTHORIZED
|
|
13
19
|
});
|
|
14
20
|
}
|
|
@@ -25,14 +31,12 @@ export const refresh = async ({ collection, req })=>{
|
|
|
25
31
|
if (collection.config.auth.removeTokenFromResponses) {
|
|
26
32
|
delete result.refreshedToken;
|
|
27
33
|
}
|
|
34
|
+
headers.set('Set-Cookie', cookie);
|
|
28
35
|
return Response.json({
|
|
29
|
-
|
|
30
|
-
message: 'Token refresh successful',
|
|
36
|
+
message: t('authentication:tokenRefreshSuccessful'),
|
|
31
37
|
...result
|
|
32
38
|
}, {
|
|
33
|
-
headers
|
|
34
|
-
'Set-Cookie': cookie
|
|
35
|
-
}),
|
|
39
|
+
headers,
|
|
36
40
|
status: httpStatus.OK
|
|
37
41
|
});
|
|
38
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/refresh.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { extractJWT } from 'payload/auth'\nimport { generatePayloadCookie } from 'payload/auth'\nimport { refreshOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const refresh: CollectionRouteHandler = async ({ collection, req }) => {\n const token = typeof req.data?.token === 'string' ? req.data.token : extractJWT(req)\n\n if (!token) {\n return Response.json(\n {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/refresh.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { extractJWT } from 'payload/auth'\nimport { generatePayloadCookie } from 'payload/auth'\nimport { refreshOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const refresh: CollectionRouteHandler = async ({ collection, req }) => {\n const { t } = req\n const token = typeof req.data?.token === 'string' ? req.data.token : extractJWT(req)\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (!token) {\n return Response.json(\n {\n message: t('error:tokenNotProvided'),\n },\n {\n headers,\n status: httpStatus.UNAUTHORIZED,\n },\n )\n }\n\n const result = await refreshOperation({\n collection,\n req,\n token,\n })\n\n const cookie = generatePayloadCookie({\n collectionConfig: collection.config,\n payload: req.payload,\n token: result.refreshedToken,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.refreshedToken\n }\n\n headers.set('Set-Cookie', cookie)\n\n return Response.json(\n {\n message: t('authentication:tokenRefreshSuccessful'),\n ...result,\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","extractJWT","generatePayloadCookie","refreshOperation","headersWithCors","refresh","collection","req","t","token","data","headers","Headers","Response","json","message","status","UNAUTHORIZED","result","cookie","collectionConfig","config","payload","refreshedToken","auth","removeTokenFromResponses","set","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,UAAU,QAAQ,eAAc;AACzC,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,gBAAgB,QAAQ,qBAAoB;AAIrD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,UAAkC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACvE,MAAM,EAAEC,CAAC,EAAE,GAAGD;IACd,MAAME,QAAQ,OAAOF,IAAIG,IAAI,EAAED,UAAU,WAAWF,IAAIG,IAAI,CAACD,KAAK,GAAGR,WAAWM;IAEhF,MAAMI,UAAUP,gBAAgB;QAC9BO,SAAS,IAAIC;QACbL;IACF;IAEA,IAAI,CAACE,OAAO;QACV,OAAOI,SAASC,IAAI,CAClB;YACEC,SAASP,EAAE;QACb,GACA;YACEG;YACAK,QAAQhB,WAAWiB,YAAY;QACjC;IAEJ;IAEA,MAAMC,SAAS,MAAMf,iBAAiB;QACpCG;QACAC;QACAE;IACF;IAEA,MAAMU,SAASjB,sBAAsB;QACnCkB,kBAAkBd,WAAWe,MAAM;QACnCC,SAASf,IAAIe,OAAO;QACpBb,OAAOS,OAAOK,cAAc;IAC9B;IAEA,IAAIjB,WAAWe,MAAM,CAACG,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOP,OAAOK,cAAc;IAC9B;IAEAZ,QAAQe,GAAG,CAAC,cAAcP;IAE1B,OAAON,SAASC,IAAI,CAClB;QACEC,SAASP,EAAE;QACX,GAAGU,MAAM;IACX,GACA;QACEP;QACAK,QAAQhB,WAAW2B,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerFirstUser.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/registerFirstUser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registerFirstUser.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/registerFirstUser.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,iBAAiB,EAAE,sBA6C/B,CAAA"}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
2
|
import { generatePayloadCookie } from 'payload/auth';
|
|
3
|
+
import { ValidationError } from 'payload/errors';
|
|
3
4
|
import { registerFirstUserOperation } from 'payload/operations';
|
|
5
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
4
6
|
export const registerFirstUser = async ({ collection, req })=>{
|
|
5
|
-
const data = req
|
|
7
|
+
const { data, t } = req;
|
|
8
|
+
if (data?.password !== data['confirm-password']) {
|
|
9
|
+
throw new ValidationError([
|
|
10
|
+
{
|
|
11
|
+
field: 'confirm-password',
|
|
12
|
+
message: req.t('Password and confirm password fields do not match.')
|
|
13
|
+
}
|
|
14
|
+
]);
|
|
15
|
+
}
|
|
6
16
|
const result = await registerFirstUserOperation({
|
|
7
17
|
collection,
|
|
8
18
|
data: {
|
|
@@ -19,13 +29,15 @@ export const registerFirstUser = async ({ collection, req })=>{
|
|
|
19
29
|
});
|
|
20
30
|
return Response.json({
|
|
21
31
|
exp: result.exp,
|
|
22
|
-
|
|
23
|
-
message: 'Successfully registered first user.',
|
|
32
|
+
message: t('authentication:successfullyRegisteredFirstUser'),
|
|
24
33
|
token: result.token,
|
|
25
34
|
user: result.user
|
|
26
35
|
}, {
|
|
27
|
-
headers:
|
|
28
|
-
|
|
36
|
+
headers: headersWithCors({
|
|
37
|
+
headers: new Headers({
|
|
38
|
+
'Set-Cookie': cookie
|
|
39
|
+
}),
|
|
40
|
+
req
|
|
29
41
|
}),
|
|
30
42
|
status: httpStatus.OK
|
|
31
43
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/registerFirstUser.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie } from 'payload/auth'\nimport { registerFirstUserOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const registerFirstUser: CollectionRouteHandler = async ({ collection, req }) => {\n const data = req
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/registerFirstUser.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie } from 'payload/auth'\nimport { ValidationError } from 'payload/errors'\nimport { registerFirstUserOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const registerFirstUser: CollectionRouteHandler = async ({ collection, req }) => {\n const { data, t } = req\n\n if (data?.password !== data['confirm-password']) {\n throw new ValidationError([\n {\n field: 'confirm-password',\n message: req.t('Password and confirm password fields do not match.'),\n },\n ])\n }\n\n const result = await registerFirstUserOperation({\n collection,\n data: {\n ...data,\n email: typeof data?.email === 'string' ? data.email : '',\n password: typeof data?.password === 'string' ? data.password : '',\n },\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionConfig: collection.config,\n payload: req.payload,\n token: result.token,\n })\n\n return Response.json(\n {\n exp: result.exp,\n message: t('authentication:successfullyRegisteredFirstUser'),\n token: result.token,\n user: result.user,\n },\n {\n headers: headersWithCors({\n headers: new Headers({\n 'Set-Cookie': cookie,\n }),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","generatePayloadCookie","ValidationError","registerFirstUserOperation","headersWithCors","registerFirstUser","collection","req","data","t","password","field","message","result","email","cookie","collectionConfig","config","payload","token","Response","json","exp","user","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,eAAe,QAAQ,iBAAgB;AAChD,SAASC,0BAA0B,QAAQ,qBAAoB;AAI/D,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,oBAA4C,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACjF,MAAM,EAAEC,IAAI,EAAEC,CAAC,EAAE,GAAGF;IAEpB,IAAIC,MAAME,aAAaF,IAAI,CAAC,mBAAmB,EAAE;QAC/C,MAAM,IAAIN,gBAAgB;YACxB;gBACES,OAAO;gBACPC,SAASL,IAAIE,CAAC,CAAC;YACjB;SACD;IACH;IAEA,MAAMI,SAAS,MAAMV,2BAA2B;QAC9CG;QACAE,MAAM;YACJ,GAAGA,IAAI;YACPM,OAAO,OAAON,MAAMM,UAAU,WAAWN,KAAKM,KAAK,GAAG;YACtDJ,UAAU,OAAOF,MAAME,aAAa,WAAWF,KAAKE,QAAQ,GAAG;QACjE;QACAH;IACF;IAEA,MAAMQ,SAASd,sBAAsB;QACnCe,kBAAkBV,WAAWW,MAAM;QACnCC,SAASX,IAAIW,OAAO;QACpBC,OAAON,OAAOM,KAAK;IACrB;IAEA,OAAOC,SAASC,IAAI,CAClB;QACEC,KAAKT,OAAOS,GAAG;QACfV,SAASH,EAAE;QACXU,OAAON,OAAOM,KAAK;QACnBI,MAAMV,OAAOU,IAAI;IACnB,GACA;QACEC,SAASpB,gBAAgB;YACvBoB,SAAS,IAAIC,QAAQ;gBACnB,cAAcV;YAChB;YACAR;QACF;QACAmB,QAAQ1B,WAAW2B,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resetPassword.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/resetPassword.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"resetPassword.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/resetPassword.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,aAAa,EAAE,sBAuC3B,CAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
2
|
import { generatePayloadCookie } from 'payload/auth';
|
|
3
3
|
import { resetPasswordOperation } from 'payload/operations';
|
|
4
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
4
5
|
export const resetPassword = async ({ collection, req })=>{
|
|
5
|
-
const { searchParams } = req;
|
|
6
|
+
const { searchParams, t } = req;
|
|
6
7
|
const depth = searchParams.get('depth');
|
|
7
8
|
const result = await resetPasswordOperation({
|
|
8
9
|
collection,
|
|
@@ -22,12 +23,14 @@ export const resetPassword = async ({ collection, req })=>{
|
|
|
22
23
|
delete result.token;
|
|
23
24
|
}
|
|
24
25
|
return Response.json({
|
|
25
|
-
|
|
26
|
-
message: 'Password reset successfully.',
|
|
26
|
+
message: t('authentication:passwordResetSuccessfully'),
|
|
27
27
|
...result
|
|
28
28
|
}, {
|
|
29
|
-
headers:
|
|
30
|
-
|
|
29
|
+
headers: headersWithCors({
|
|
30
|
+
headers: new Headers({
|
|
31
|
+
'Set-Cookie': cookie
|
|
32
|
+
}),
|
|
33
|
+
req
|
|
31
34
|
}),
|
|
32
35
|
status: httpStatus.OK
|
|
33
36
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/resetPassword.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie } from 'payload/auth'\nimport { resetPasswordOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const resetPassword: CollectionRouteHandler = async ({ collection, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const result = await resetPasswordOperation({\n collection,\n data: {\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n token: typeof req.data?.token === 'string' ? req.data.token : '',\n },\n depth: depth ? Number(depth) : undefined,\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionConfig: collection.config,\n payload: req.payload,\n token: result.token,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/resetPassword.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie } from 'payload/auth'\nimport { resetPasswordOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const resetPassword: CollectionRouteHandler = async ({ collection, req }) => {\n const { searchParams, t } = req\n const depth = searchParams.get('depth')\n\n const result = await resetPasswordOperation({\n collection,\n data: {\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n token: typeof req.data?.token === 'string' ? req.data.token : '',\n },\n depth: depth ? Number(depth) : undefined,\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionConfig: collection.config,\n payload: req.payload,\n token: result.token,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n message: t('authentication:passwordResetSuccessfully'),\n ...result,\n },\n {\n headers: headersWithCors({\n headers: new Headers({\n 'Set-Cookie': cookie,\n }),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","generatePayloadCookie","resetPasswordOperation","headersWithCors","resetPassword","collection","req","searchParams","t","depth","get","result","data","password","token","Number","undefined","cookie","collectionConfig","config","payload","auth","removeTokenFromResponses","Response","json","message","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,sBAAsB,QAAQ,qBAAoB;AAI3D,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,gBAAwC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IAC7E,MAAM,EAAEC,YAAY,EAAEC,CAAC,EAAE,GAAGF;IAC5B,MAAMG,QAAQF,aAAaG,GAAG,CAAC;IAE/B,MAAMC,SAAS,MAAMT,uBAAuB;QAC1CG;QACAO,MAAM;YACJC,UAAU,OAAOP,IAAIM,IAAI,EAAEC,aAAa,WAAWP,IAAIM,IAAI,CAACC,QAAQ,GAAG;YACvEC,OAAO,OAAOR,IAAIM,IAAI,EAAEE,UAAU,WAAWR,IAAIM,IAAI,CAACE,KAAK,GAAG;QAChE;QACAL,OAAOA,QAAQM,OAAON,SAASO;QAC/BV;IACF;IAEA,MAAMW,SAAShB,sBAAsB;QACnCiB,kBAAkBb,WAAWc,MAAM;QACnCC,SAASd,IAAIc,OAAO;QACpBN,OAAOH,OAAOG,KAAK;IACrB;IAEA,IAAIT,WAAWc,MAAM,CAACE,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOX,OAAOG,KAAK;IACrB;IAEA,OAAOS,SAASC,IAAI,CAClB;QACEC,SAASjB,EAAE;QACX,GAAGG,MAAM;IACX,GACA;QACEe,SAASvB,gBAAgB;YACvBuB,SAAS,IAAIC,QAAQ;gBACnB,cAAcV;YAChB;YACAX;QACF;QACAsB,QAAQ5B,WAAW6B,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlock.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/unlock.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"unlock.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/unlock.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,MAAM,EAAE,sBAqBpB,CAAA"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
2
|
import { unlockOperation } from 'payload/operations';
|
|
3
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
3
4
|
export const unlock = async ({ collection, req })=>{
|
|
5
|
+
const { t } = req;
|
|
4
6
|
await unlockOperation({
|
|
5
7
|
collection,
|
|
6
8
|
data: {
|
|
@@ -9,9 +11,12 @@ export const unlock = async ({ collection, req })=>{
|
|
|
9
11
|
req
|
|
10
12
|
});
|
|
11
13
|
return Response.json({
|
|
12
|
-
|
|
13
|
-
message: 'Success'
|
|
14
|
+
message: t('general:success')
|
|
14
15
|
}, {
|
|
16
|
+
headers: headersWithCors({
|
|
17
|
+
headers: new Headers(),
|
|
18
|
+
req
|
|
19
|
+
}),
|
|
15
20
|
status: httpStatus.OK
|
|
16
21
|
});
|
|
17
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/unlock.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { unlockOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const unlock: CollectionRouteHandler = async ({ collection, req }) => {\n await unlockOperation({\n collection,\n data: { email: req.data.email as string },\n req,\n })\n\n return Response.json(\n {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/unlock.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { unlockOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const unlock: CollectionRouteHandler = async ({ collection, req }) => {\n const { t } = req\n\n await unlockOperation({\n collection,\n data: { email: req.data.email as string },\n req,\n })\n\n return Response.json(\n {\n message: t('general:success'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","unlockOperation","headersWithCors","unlock","collection","req","t","data","email","Response","json","message","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,qBAAoB;AAIpD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,SAAiC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACtE,MAAM,EAAEC,CAAC,EAAE,GAAGD;IAEd,MAAMJ,gBAAgB;QACpBG;QACAG,MAAM;YAAEC,OAAOH,IAAIE,IAAI,CAACC,KAAK;QAAW;QACxCH;IACF;IAEA,OAAOI,SAASC,IAAI,CAClB;QACEC,SAASL,EAAE;IACb,GACA;QACEM,SAASV,gBAAgB;YACvBU,SAAS,IAAIC;YACbR;QACF;QACAS,QAAQd,WAAWe,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyEmail.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/verifyEmail.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"verifyEmail.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/verifyEmail.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAI/D,eAAO,MAAM,WAAW,EAAE,4BAoBzB,CAAA"}
|