From 533c04d9558bd0a575671c157ca42236f59a2c5a Mon Sep 17 00:00:00 2001
From: physcik <mynameisgennadiy@vk.com>
Date: Tue, 28 Apr 2026 23:33:59 +0500
Subject: frontend auth

---
 front/src/App.tsx | 42 +++++++++++++++++++++++++++++-------------
 1 file changed, 29 insertions(+), 13 deletions(-)

(limited to 'front/src/App.tsx')

diff --git a/front/src/App.tsx b/front/src/App.tsx
index 2f69086..c106139 100644
--- a/front/src/App.tsx
+++ b/front/src/App.tsx
@@ -6,11 +6,15 @@ import IndexElement from './Emelents/IndexElement';
 import ClassesList from './Emelents/ClassList';
 import Topbar from './Emelents/Topbar';
 import { AllowedLanguages, LanguageContext } from './Locales/Context';
-import { useState } from 'react';
+import { useEffect, useState } from 'react';
 import { ReadCurrentLocale, SaveCurrentLocale } from './Locales/Locales';
 import LegalNote from './Emelents/LegalNote';
 import WeaponsIndex from './Pages/Weapons';
 import RangedWeaponPage from './Pages/RangedWeapon';
+import { AuthContext, Authentication, GetUserInfo } from './Authentication/ContextProvider';
+import { useCookies } from 'react-cookie';
+import LoginPage from './Authentication/LoginPage';
+import { User } from './Authentication/Models';
 
 const router = createBrowserRouter([
     {
@@ -29,6 +33,10 @@ const router = createBrowserRouter([
         path: "/weapons/:id",
         element: (<RangedWeaponPage />),
     },
+    {
+        path: "/login",
+        element: (<LoginPage />),
+    },
 ]);
 
 function App() {
@@ -40,20 +48,28 @@ function App() {
         setLang(newLang);
     }
 
+    const [authCookie, ] = useCookies(['X-AUTH-TOKEN']);
+    const [auth, setAuth] = useState<User | null>(null);
+    useEffect(() => {
+        GetUserInfo(authCookie['X-AUTH-TOKEN']).then(v => setAuth(v));
+    }, []);
+
     return (
-        <LanguageContext.Provider value={lang}>
-            <div className='App'>
-                <Topbar />
-                <div className='AppContents'>
-                    <Sidebar 
-                        setLang={SetLanguage}
-                        />
-                    <RouterProvider router={router} />
+        <AuthContext.Provider value={auth}>
+            <LanguageContext.Provider value={lang}>
+                <div className='App'>
+                    <Topbar />
+                    <div className='AppContents'>
+                        <Sidebar 
+                            setLang={SetLanguage}
+                            />
+                        <RouterProvider router={router} />
+                    </div>
+                    <LegalNote />
                 </div>
-                <LegalNote />
-            </div>
-        </LanguageContext.Provider>
+            </LanguageContext.Provider>
+        </AuthContext.Provider>
     );
 }
 
-export default App;
+export default App; 
-- 
cgit v1.3

