Skip to content

Commit

Permalink
Merge pull request #78 from Beside-Potenday/seungbeom
Browse files Browse the repository at this point in the history
fix: 로그인 리다이렉트 수정
  • Loading branch information
seung365 authored Aug 7, 2024
2 parents e345cfb + 0589498 commit 702a3c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/routes/components/PrivateRoute.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useAuth } from '@/Provider/Auth';
import { RouterPath } from '../path';
import { Navigate, Outlet } from 'react-router-dom';
import { getDynamicPath } from '../path';

export const PrivateRoute = () => {
const { authInfo } = useAuth();
const authInfo = useAuth();

if (!authInfo) {
return <Navigate to={RouterPath.login} />;
return <Navigate to={getDynamicPath.login()} />;
}

return <Outlet />;
Expand Down
7 changes: 7 additions & 0 deletions src/routes/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ export const RouterPath = {
auth: '/auth',
notFound: '*',
};

export const getDynamicPath = {
login: (redirect?: string) => {
const currentRedirect = redirect ?? window.location.href;
return `${RouterPath.login}?redirect=${encodeURIComponent(currentRedirect)}`;
},
};

0 comments on commit 702a3c6

Please sign in to comment.