Skip to content

Commit

Permalink
fix(login): 로그아웃 오류 수정 (#81)
Browse files Browse the repository at this point in the history
* fix

* fix
  • Loading branch information
Collection50 committed Sep 7, 2024
1 parent 6f0629a commit 2939cb5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/app/(sidebar)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { NotificatinProvider } from '@/components/Notification/context';
export default function SidebarLayout({ children }: PropsWithChildren) {
return (
<div className="flex">
<NotificatinProvider>
<Sidebar />
<div className="flex-grow relative">
<AuthRedirect>
<AuthRedirect>
<NotificatinProvider>
<Sidebar />
<div className="flex-grow relative">
<CardWindowLayout>{children}</CardWindowLayout>
<NotificationWindow />
</AuthRedirect>
</div>
</NotificatinProvider>
</div>
</NotificatinProvider>
</AuthRedirect>
</div>
);
}
5 changes: 3 additions & 2 deletions src/app/AuthRedirect.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { cookies } from 'next/headers';
import { ACCESS_TOKEN, JOB_SELECTION } from './login/constants/token';
import { ACCESS_TOKEN, JOB_SELECTION, REFRESH_TOKEN } from './login/constants/token';
import { redirect } from 'next/navigation';
import type { StrictPropsWithChildren } from '@/types';

export default async function AuthRedirect({ children }: StrictPropsWithChildren) {
const accessToken = cookies().get(ACCESS_TOKEN)?.value;
const isJobSelection = cookies().get(JOB_SELECTION)?.value;

if (accessToken == null || isJobSelection == null) {
if (!accessToken || !isJobSelection) {
cookies().delete(ACCESS_TOKEN);
cookies().delete(REFRESH_TOKEN);
cookies().delete(JOB_SELECTION);
redirect('/login');
}
Expand Down
1 change: 1 addition & 0 deletions src/container/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function Sidebar() {
const logout = () => {
deleteCookie('accessToken');
deleteCookie('refreshToken');
deleteCookie('jobSelection');
router.push('/login');
};

Expand Down

0 comments on commit 2939cb5

Please sign in to comment.