payload
Version:
Node, React, Headless CMS and Application Framework built on Next.js
30 lines (29 loc) • 1.04 kB
JavaScript
import { status as httpStatus } from 'http-status';
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
import { headersWithCors } from '../../utilities/headersWithCors.js';
import { unlockOperation } from '../operations/unlock.js';
export const unlockHandler = async (req)=>{
const collection = getRequestCollection(req);
const { t } = req;
const authData = collection.config.auth?.loginWithUsername !== false ? {
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 unlockOperation({
collection,
data: authData,
req
});
return Response.json({
message: t('general:success')
}, {
headers: headersWithCors({
headers: new Headers(),
req
}),
status: httpStatus.OK
});
};
//# sourceMappingURL=unlock.js.map