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 ( );