From 4a44968b896415fb309f7113ebc477c84ff5b5ce Mon Sep 17 00:00:00 2001 From: inmake Date: Tue, 7 Oct 2025 21:11:56 +0500 Subject: [PATCH] Refactor HomePage to use custom Button component; enhance login service to fetch user with full relations for improved data handling. --- client/src/pages/HomePage.tsx | 5 +++-- server/src/services/auth/login.ts | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/client/src/pages/HomePage.tsx b/client/src/pages/HomePage.tsx index 2ab2c3d..2ee2aef 100644 --- a/client/src/pages/HomePage.tsx +++ b/client/src/pages/HomePage.tsx @@ -1,3 +1,4 @@ +import Button from "../components/ui/Button"; import { useMe, useLogout } from "../hooks/useAuth"; import { useNavigate } from "react-router"; @@ -70,13 +71,13 @@ function HomePage() { )} - + diff --git a/server/src/services/auth/login.ts b/server/src/services/auth/login.ts index 8928693..52cd96c 100644 --- a/server/src/services/auth/login.ts +++ b/server/src/services/auth/login.ts @@ -37,12 +37,17 @@ export const loginService = { metadata ); + // Получить пользователя с полными данными (филиал и компания) + const userWithRelations = await userService.findByIdWithRelations(user.id); + // Вычислить дату истечения токена const expiresAt = new Date(); expiresAt.setDate(expiresAt.getDate() + 7); return { - user: userService.sanitize(user), + user: userWithRelations + ? userService.sanitizeWithRelations(userWithRelations) + : userService.sanitize(user), session: { id: sessionId, token: accessToken,