Skip to content

Commit 40174ad

Browse files
committed
feat: 회원 가입 후 인증 설정
1 parent 7cce71f commit 40174ad

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/App.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
import { RouterProvider } from 'react-router-dom';
44

55
import { router } from '@/routes/router';
6+
import { refreshAuthAtom } from '@/store/auth';
7+
import { useSetAtom } from 'jotai';
8+
import { useEffect } from 'react';
69

710
export const App = () => {
8-
// const refreshAuth = useSetAtom(refreshAuthAtom);
11+
const refreshAuth = useSetAtom(refreshAuthAtom);
912

10-
// useEffect(() => {
11-
// refreshAuth();
12-
// }, []);
13+
useEffect(() => {
14+
refreshAuth();
15+
}, []);
1316

1417
return <RouterProvider router={router} />;
1518
};

src/routes/router.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ const useAuth = () => {
4343

4444
const PrivateRoute = ({ children }: { children: React.ReactNode }) => {
4545
const { isAuthenticated } = useAuth();
46-
console.log('PrivateRoute isAuthenticated', isAuthenticated);
4746
const location = useLocation();
4847

4948
if (!isAuthenticated) {

src/templates/User/EnrollSubmitButton.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import { useLocation, useNavigate } from 'react-router-dom';
44

55
import { createProfile } from '@/api/user';
66
import { PATH } from '@/routes/path';
7-
import { isSubmittedAtom } from '@/store/form';
7+
import { refreshAuthAtom } from '@/store/auth';
88
import {
99
formTextInputAtom,
1010
formTextareaAtom,
1111
imageAtom,
1212
isEnrollSatisfiedAtom,
13+
isSubmittedAtom,
1314
} from '@/store/form';
1415
import { alertAtom } from '@/store/modal';
1516
import { useAtomValue, useSetAtom } from 'jotai';
@@ -23,16 +24,18 @@ export const EnrollSubmitButton = () => {
2324
const location = useLocation();
2425
const setAlert = useSetAtom(alertAtom);
2526
const setIsSubmitted = useSetAtom(isSubmittedAtom);
27+
const refreshAuth = useSetAtom(refreshAuthAtom);
2628

2729
const onClick = () => {
2830
createProfile({
2931
memberName: memberName,
3032
memberExplain: memberExplain,
3133
image: image,
3234
})
33-
.then(() => {
35+
.then(async () => {
3436
// const previousPath = location.state?.redirect ?? PATH.TEAMS;
3537
// navigate(previousPath);
38+
await refreshAuth();
3639
setIsSubmitted(true);
3740

3841
const navigatePath = location.state?.redirect

0 commit comments

Comments
 (0)