-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: 하단에 hidden component를 추가하여 relative하게 중앙 정렬 * feat: 마이페이지에 계정 탈퇴 메뉴 추가 * refactor: useQuery로 api 호출 방식 변경 * feat: privateRoute hooks 구현 * feat: Nav Bar 로그아웃 기능 추가 * refactor: privateRoute에서 로그아웃 후 login 페이지로 이동하는 방식으로 변경 * refactor: PrivateRoute outlet 중첩 라우팅으로 수정 * fix: 기존에 userState 사용하는 로직 삭제, resetUserInfo 적용 * refactor: useQuery에서 useMutation으로 변경, useCurrentPasswordForm 내부로 위치 변경 * fix: resetUserInfo 중복 선언 제거 * fix: PrivateRoute 적용 페이지 추가
- Loading branch information
Showing
9 changed files
with
84 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,11 @@ | ||
import { AxiosError } from 'axios'; | ||
|
||
import { authClient } from '@/apis'; | ||
import { AuthErrorData } from '@/home/types/Auth.type'; | ||
import { GetPasswordResponse } from '@/home/types/password.type'; | ||
import { SessionTokenType } from '@/home/types/password.type'; | ||
import { api } from '@/service/TokenService'; | ||
|
||
interface getPasswordProps { | ||
password: string; | ||
} | ||
|
||
export const getUserPasswordMatch = async ( | ||
props: getPasswordProps | ||
): Promise<GetPasswordResponse> => { | ||
const { password } = props; | ||
|
||
try { | ||
const res = await authClient.get('/auth/verification/password', { | ||
params: { password }, | ||
headers: api.headers, | ||
}); | ||
return { data: res.data }; | ||
} catch (error: unknown) { | ||
return { error: error as AxiosError<AuthErrorData> }; | ||
} | ||
export const getUserPasswordMatch = async (password: string): Promise<SessionTokenType> => { | ||
const res = await authClient.get('/auth/verification/password', { | ||
params: { password }, | ||
headers: api.headers, | ||
}); | ||
return res.data; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Navigate, Outlet } from 'react-router-dom'; | ||
import { useRecoilValue } from 'recoil'; | ||
|
||
import { LogInState } from '@/home/recoil/LogInState'; | ||
import { api } from '@/service/TokenService'; | ||
|
||
import { useResetUserInfo } from './useResetUserInfo'; | ||
|
||
export const usePrivateRoute = () => { | ||
const isLoggedIn = useRecoilValue(LogInState); | ||
const accessToken = api.getAccessToken(); | ||
|
||
const resetUserInfo = useResetUserInfo(); | ||
|
||
const PrivateRoute = (): React.ReactNode => { | ||
if (!isLoggedIn || !accessToken) { | ||
resetUserInfo(); | ||
return <Navigate to="/login" />; | ||
} | ||
return <Outlet />; | ||
}; | ||
|
||
return { PrivateRoute }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters