Skip to content

Commit

Permalink
Allow user to access login page when logged in (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
PatFawbertMills authored Jan 7, 2025
1 parent 3d86500 commit 6d5185b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { createBrowserRouter, RouterProvider } from 'react-router-dom'

import { useAuth } from '@/hooks/useAuth'

import { ProtectedRoute } from './ProtectedRoute'
import Root from '@/Root'
import Login from '@/views/auth/Login'
Expand Down Expand Up @@ -91,10 +89,8 @@ const unauthenticatedRoutes = [
]

const Routes = () => {
const { token } = useAuth()

const router = createBrowserRouter([
...(!token ? unauthenticatedRoutes : []),
...unauthenticatedRoutes,
...authenticatedRoutes,
])

Expand Down
2 changes: 2 additions & 0 deletions src/views/auth/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { LoginForm } from '@/components/forms/LoginForm'

export default function Login() {
// TODO: redirect user to the index page if they are already authenticated
// const { token } = useAuth()
return (
<>
<LoginForm />
Expand Down

0 comments on commit 6d5185b

Please sign in to comment.