Skip to content

Commit

Permalink
fix: 리다이렉트 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene028 committed Aug 7, 2024
1 parent dee2194 commit 17a8c6d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 103 deletions.
25 changes: 19 additions & 6 deletions src/components/auth/guard/AuthAccessGuard.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import RoutePath from '@/routes/routePath';
import { isAuthenticated } from '@/utils/auth';
import { toast } from 'react-toastify';
import { Outlet, Navigate } from 'react-router-dom';
import { useNavigate, Outlet } from 'react-router-dom';
import { useEffect, useState } from 'react';

export default function AuthAccessGuard() {
if (isAuthenticated()) return <Outlet />;
else {
toast.error('로그인이 필요한 서비스예요.');
return <Navigate to={RoutePath.Home} />;
}
const navigate = useNavigate();
const [redirect, setRedirect] = useState(false);

useEffect(() => {
if (!isAuthenticated()) {
toast.error('로그인이 필요한 서비스예요.');
setRedirect(true);
}
}, []);

useEffect(() => {
if (redirect) {
navigate(RoutePath.Home);
}
}, [redirect, navigate]);

return isAuthenticated() ? <Outlet /> : null;
}
95 changes: 0 additions & 95 deletions src/pages/OnboardingClosed.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions src/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ export * from './MyPageEdit';
export * from './SignUp';
export * from './StudentVerification';
export { default as UpdatedStudentVerification } from './UpdatedStudentVerification';
export { default as OnboardingNotOpened } from './OnboardingNotOpened';
export { default as OnboardingClosed } from './OnboardingClosed';
export * from './redirect/AuthServerRedirectNavigate';
export * from './redirect/StudentVerificationServerRedirect';
export * from './PaymentsCheckout';
Expand Down

0 comments on commit 17a8c6d

Please sign in to comment.