Skip to content

Commit

Permalink
fixed redirect when auth is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
marcopiovanello committed Dec 3, 2023
1 parent 0ab9f15 commit 70a8d27
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion frontend/src/components/SocketSubscriber.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as O from 'fp-ts/Option'
import { useEffect, useMemo } from 'react'
import { useNavigate } from 'react-router-dom'
import { useRecoilState, useRecoilValue } from 'recoil'
import { take, timer } from 'rxjs'
import { downloadsState } from '../atoms/downloads'
Expand All @@ -23,6 +24,8 @@ const SocketSubscriber: React.FC<Props> = () => {
const { client } = useRPC()
const { pushMessage } = useToast()

const navigate = useNavigate()

const socketOnce$ = useMemo(() => client.socket$.pipe(take(1)), [])

useEffect(() => {
Expand Down Expand Up @@ -60,7 +63,8 @@ const SocketSubscriber: React.FC<Props> = () => {
pushMessage(
`${i18n.t('rpcConnErr')} (${serverAddressAndPort})`,
"error"
)
),
navigate(`/error`)
}
)

Expand Down
8 changes: 8 additions & 0 deletions frontend/src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ export const router = createHashRouter([
</Suspense >
)
},
{
path: '/error',
element: (
<Suspense fallback={<CircularProgress />}>
<ErrorBoundary />
</Suspense >
)
},
]
},
])
1 change: 0 additions & 1 deletion frontend/src/views/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export default function Login() {
username,
password,
}),
redirect: 'follow'
})

pipe(
Expand Down

0 comments on commit 70a8d27

Please sign in to comment.