UNPKG

payload

Version:

Node, React, Headless CMS and Application Framework built on Next.js

33 lines (32 loc) 1.24 kB
// @ts-strict-ignore import { status as httpStatus } from 'http-status'; import { getRequestCollection } from '../../utilities/getRequestEntity.js'; import { headersWithCors } from '../../utilities/headersWithCors.js'; import { forgotPasswordOperation } from '../operations/forgotPassword.js'; export const forgotPasswordHandler = async (req)=>{ const { t } = req; const collection = getRequestCollection(req); const authData = collection.config.auth?.loginWithUsername ? { email: typeof req.data?.email === 'string' ? req.data.email : '', username: typeof req.data?.username === 'string' ? req.data.username : '' } : { email: typeof req.data?.email === 'string' ? req.data.email : '' }; await forgotPasswordOperation({ collection, data: authData, disableEmail: Boolean(req.data?.disableEmail), expiration: typeof req.data.expiration === 'number' ? req.data.expiration : undefined, req }); return Response.json({ message: t('general:success') }, { headers: headersWithCors({ headers: new Headers(), req }), status: httpStatus.OK }); }; //# sourceMappingURL=forgotPassword.js.map