From 0e024b00a1d396f9bba6f383e517d4fcdddd5d07 Mon Sep 17 00:00:00 2001 From: Redsandyg Date: Tue, 3 Jun 2025 17:28:15 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BD=D0=B0=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=B2=20=D0=BA=D1=83=D0=BA=D0=B8=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=20=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B8=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B5=D0=B3=D0=BE=20=D0=B2=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=B2=D0=B8=D0=B3=D0=B0=D1=86=D0=B8=D0=B8.=20=D0=9E?= =?UTF-8?q?=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=20=D0=BA=D0=BE=D0=BC?= =?UTF-8?q?=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=20Navigation=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=BF=D0=B5=D1=80=D0=B2=D1=8B=D1=85=20?= =?UTF-8?q?=D0=B4=D0=B2=D1=83=D1=85=20=D0=B1=D1=83=D0=BA=D0=B2=20=D0=BB?= =?UTF-8?q?=D0=BE=D0=B3=D0=B8=D0=BD=D0=B0=20=D0=B8=D0=BB=D0=B8=20=D0=B8?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B8=20=D0=BF=D0=BE=20=D1=83=D0=BC=D0=BE?= =?UTF-8?q?=D0=BB=D1=87=D0=B0=D0=BD=D0=B8=D1=8E.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/auth/page.tsx | 5 +++-- src/components/Navigation.tsx | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/app/auth/page.tsx b/src/app/auth/page.tsx index 71975de..4b9b045 100644 --- a/src/app/auth/page.tsx +++ b/src/app/auth/page.tsx @@ -52,8 +52,9 @@ export default function AuthPage() { return; } const data = await res.json(); - // Сохраняем токен в куки на 60 минут через js-cookie - Cookies.set('access_token', data.access_token, { expires: 1/24, path: '/', sameSite: 'strict'}); + // Сохраняем токен и логин в куки на 60 минут через js-cookie + Cookies.set('access_token', data.access_token, { expires: 1/24, path: '/' }); + Cookies.set('user_login', email, { expires: 1/24, path: '/' }); setError(""); window.location.href = "/"; } catch (err) { diff --git a/src/components/Navigation.tsx b/src/components/Navigation.tsx index 255887d..13e7296 100644 --- a/src/components/Navigation.tsx +++ b/src/components/Navigation.tsx @@ -2,6 +2,8 @@ import Link from "next/link"; import { usePathname } from "next/navigation"; import styles from "../styles/navigation.module.css"; +import Cookies from "js-cookie"; +import { useEffect, useState } from "react"; interface NavItem { id: string; @@ -17,6 +19,15 @@ const navItems: NavItem[] = [ const Navigation: React.FC = () => { const pathname = usePathname(); + const [login, setLogin] = useState(""); + + useEffect(() => { + if (typeof document !== "undefined") { + const userLogin = Cookies.get('user_login'); + if (userLogin) setLogin(userLogin); + } + }, []); + if (pathname === "/auth") return null; return ( );