Files
klz-cables.com/.pnpm-store/v10/files/3f/5982ed367d3eaa5950bd343e9e2a8736adc09d235f206261439c5ec24b206ede727e1bd30c358f92e80084ecad6823fff42999c8c8f58d2061e14435e9b0c3
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

46 lines
1.7 KiB
Plaintext

import { status as httpStatus } from 'http-status';
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
import { headersWithCors } from '../../utilities/headersWithCors.js';
import { generatePayloadCookie } from '../cookies.js';
import { registerFirstUserOperation } from '../operations/registerFirstUser.js';
export const registerFirstUserHandler = async (req)=>{
const collection = getRequestCollection(req);
const { data, t } = req;
const authData = collection.config.auth?.loginWithUsername ? {
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 registerFirstUserOperation({
collection,
data: {
...data,
...authData
},
req
});
const cookie = generatePayloadCookie({
collectionAuthConfig: collection.config.auth,
cookiePrefix: req.payload.config.cookiePrefix,
token: result.token
});
return Response.json({
exp: result.exp,
message: t('authentication:successfullyRegisteredFirstUser'),
token: result.token,
user: result.user
}, {
headers: headersWithCors({
headers: new Headers({
'Set-Cookie': cookie
}),
req
}),
status: httpStatus.OK
});
};
//# sourceMappingURL=registerFirstUser.js.map