feat(F-054): completed feature
This commit is contained in:
@@ -107,7 +107,20 @@ export async function registerBackofficeRoutes(
|
||||
};
|
||||
|
||||
app.post('/backoffice/auth/login', { schema: loginSchema }, async (request, reply) => {
|
||||
const input = credentialsSchema.parse(request.body);
|
||||
const parseResult = credentialsSchema.safeParse(request.body);
|
||||
if (!parseResult.success) {
|
||||
throw new AppError(
|
||||
400,
|
||||
'VALIDATION_ERROR',
|
||||
'Invalid request payload',
|
||||
parseResult.error.issues.map((issue) => ({
|
||||
path: issue.path.join('.'),
|
||||
message: issue.message,
|
||||
code: issue.code,
|
||||
})),
|
||||
);
|
||||
}
|
||||
const input = parseResult.data;
|
||||
try {
|
||||
const result = await login.execute(input);
|
||||
setCookie(reply, result.token, true);
|
||||
|
||||
Reference in New Issue
Block a user