Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
32 lines
1.2 KiB
Plaintext
32 lines
1.2 KiB
Plaintext
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 |