fix: authorization / registration

This commit is contained in:
2026-05-10 19:45:39 +03:00
parent 9709bb9d7b
commit f489063a6a
2 changed files with 17 additions and 2 deletions

View File

@@ -0,0 +1,11 @@
import { Navigate, Outlet } from 'react-router-dom'
import { useIsAuthenticated } from '@features/auth'
import { ROUTES } from '@shared/config/routes'
export function GuestRoute() {
const { isAuthenticated, isLoading } = useIsAuthenticated()
if (isLoading) return null
if (isAuthenticated) return <Navigate to={ROUTES.WALLET} replace />
return <Outlet />
}

View File

@@ -9,6 +9,7 @@ import { SeedPhrasePage } from '@pages/seed-phrase'
import { ROUTES } from '@shared/config/routes' import { ROUTES } from '@shared/config/routes'
import { ScrollToTop } from './ScrollToTop' import { ScrollToTop } from './ScrollToTop'
import { ProtectedRoute } from './ProtectedRoute' import { ProtectedRoute } from './ProtectedRoute'
import { GuestRoute } from './GuestRoute'
export function RouterProvider() { export function RouterProvider() {
return ( return (
@@ -16,8 +17,11 @@ export function RouterProvider() {
<ScrollToTop /> <ScrollToTop />
<Routes> <Routes>
<Route path={ROUTES.HOME} element={<HomePage />} /> <Route path={ROUTES.HOME} element={<HomePage />} />
<Route path={ROUTES.LOGIN} element={<LoginPage />} />
<Route path={ROUTES.REGISTER} element={<RegisterPage />} /> <Route element={<GuestRoute />}>
<Route path={ROUTES.LOGIN} element={<LoginPage />} />
<Route path={ROUTES.REGISTER} element={<RegisterPage />} />
</Route>
<Route element={<ProtectedRoute />}> <Route element={<ProtectedRoute />}>
<Route path={ROUTES.WALLET} element={<WalletPage />} /> <Route path={ROUTES.WALLET} element={<WalletPage />} />