Skip to content

Commit

Permalink
misc: fix-up return to logic
Browse files Browse the repository at this point in the history
  • Loading branch information
revam committed Nov 14, 2023
1 parent d2806bd commit 409decf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core/router/AuthenticatedRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function AuthenticatedRoute(props: Props) {

return (serverState === 2 && isAuthenticated)
? props.children
: <Navigate to={`/webui/login#?returnTo=${from}`} replace />;
: <Navigate to={from === '/' || from === '/webui/' ? '/webui/login' : `/webui/login#?returnTo=${from}`} replace />;
}

export default AuthenticatedRoute;
6 changes: 3 additions & 3 deletions src/pages/login/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import { usePostAuthMutation } from '@/core/rtkQuery/splitApi/authApi';
import { useGetRandomMetadataQuery } from '@/core/rtkQuery/splitV3Api/imageApi';
import { useGetInitStatusQuery, useGetInitVersionQuery } from '@/core/rtkQuery/splitV3Api/initApi';
import { ImageTypeEnum } from '@/core/types/api/common';
import { useHashQuery } from '@/hooks/query';
import { useHashQueryParameter } from '@/hooks/query';

import type { RootState } from '@/core/store';

function LoginPage() {
const [{ returnTo = '/', ...rest }, setHashQuery] = useHashQuery();
const [returnTo, setReturnTo] = useHashQueryParameter('returnTo', '/webui/');
const navigate = useNavigate();

const apiSession = useSelector((state: RootState) => state.apiSession);
Expand All @@ -45,7 +45,7 @@ function LoginPage() {

const setRedirect = () => {
if (seriesId === 0) return;
setHashQuery({ returnTo: `/webui/collection/series/${seriesId}`, ...rest });
setReturnTo(`/webui/collection/series/${seriesId}`);
};

useEffect(() => {
Expand Down

0 comments on commit 409decf

Please sign in to comment.