Files
klz-cables.com/.pnpm-store/v10/files/31/6376ca4b39a6ad1ca567381f07285a87f9633398e636a96edb28da5db3349a61fa60627249e57caaa472eef5dcf7c26bb4d90f344a99b69f61c720833e0e81
Marc Mintel 5397309103
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
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

47 lines
1.8 KiB
Plaintext

import { status as httpStatus } from 'http-status';
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
import { headersWithCors } from '../../utilities/headersWithCors.js';
import { isNumber } from '../../utilities/isNumber.js';
import { generatePayloadCookie } from '../cookies.js';
import { loginOperation } from '../operations/login.js';
export const loginHandler = async (req)=>{
const collection = getRequestCollection(req);
const { searchParams, t } = req;
const depth = searchParams.get('depth');
const authData = collection.config.auth?.loginWithUsername !== false ? {
email: typeof req.data?.email === 'string' ? req.data.email : '',
password: typeof req.data?.password === 'string' ? req.data.password : '',
username: typeof req.data?.username === 'string' ? req.data.username : ''
} : {
email: typeof req.data?.email === 'string' ? req.data.email : '',
password: typeof req.data?.password === 'string' ? req.data.password : ''
};
const result = await loginOperation({
collection,
data: authData,
depth: isNumber(depth) ? Number(depth) : undefined,
req
});
const cookie = generatePayloadCookie({
collectionAuthConfig: collection.config.auth,
cookiePrefix: req.payload.config.cookiePrefix,
token: result.token
});
if (collection.config.auth.removeTokenFromResponses) {
delete result.token;
}
return Response.json({
message: t('authentication:passed'),
...result
}, {
headers: headersWithCors({
headers: new Headers({
'Set-Cookie': cookie
}),
req
}),
status: httpStatus.OK
});
};
//# sourceMappingURL=login.js.map