-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: accessToken 을 관리하는 localstorage 객체 생성 * feat: token storage에 setToken 메서드 추가 * feat: fetcher를 통해 요청하기 전에 access token 만료 검사 * fix: 테스트를 위해 토큰 재발급 시 요청 'GET'으로 변경 * fix: 요청 시 headers 스프레드 연산자 제거 * fix: 만료일 계산 로직 다시 설정 * fix: accessToken 만료시 요청 header 비워주도록 변경 * refactor: 만료일 계산 로직 util로 분리 * refactor: accessTokenStorage 활용하여 토큰관리 * feat: LoginPopUp 컴포넌트 구현 * refactor: AuthLayout이 필요한 page에 추가 * feat: 로그인 인증 에러 및 바운더리 추가 * feat: response ok가 아닐 경우 에러 객체 생성 * fix: auth error boundary 삭제 * feat: loginPopup 컨텍스트 구현 및 적용 * fix: 사용하지 않는 이유로 loginPopup Modal 삭제 * fix: 401 인증 실패시에 logout처리 * refactor: localstorage 로직을 accessTokenStorage에서 하도록 수정 * fix: mutate, query 시에 error 던지지 않도록 수정 * refactor: login 인증 코드가 undefined일 경우 처리 * fix: error 발생 시 불필요한 사이드 이펙트 발생 부분 제거 * feat: kakao Oauth 추가로 인한 router 및 경로 수정 * fix: 킬링파트 구간 등록시 모달 열리도록 수정 * fix: google oauth url 변경 * refactor: loginmodal message 배열에서 문자열로 받도록 수정 * feat: access token cache 기능 추가 * refactor: access token 만료 확인 로직 분리 * comment: 추후 error boundary 적용을 위한 주석 추가 * feat: login 팝업 모달 에러 코드별 처리 * style: 필요없는 주석 제거 * refactor: 불필요한 console.log 제거 * fix: 토큰 refresh 시에 GET에서 POST로 요청 메서드 변경 * feat: refresh 요청 401 응답 시 바로 error 발생
- Loading branch information
1 parent
6d9d1a5
commit d371aa3
Showing
20 changed files
with
311 additions
and
96 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
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,6 @@ | ||
import path from '@/shared/constants/path'; | ||
|
||
const DOMAIN_URL = `${process.env.BASE_URL}`?.replace(/api\/?/, ''); | ||
|
||
export const googleAuthUrl = `https://accounts.google.com/o/oauth2/v2/auth?scope=email&response_type=code&redirect_uri=${DOMAIN_URL}${path.GOOGLE_REDIRECT}&client_id=405219607197-qfpt1e3v1bm25ebvadt5bvttskse5vpg.apps.googleusercontent.com`; | ||
export const kakaoAuthUrl = `https://kauth.kakao.com/oauth/authorize?response_type=code&client_id=1808b8a2e3f29fbae5b54adc357a0692&redirect_uri=${DOMAIN_URL}${path.KAKAO_REDIRECT}`; |
This file was deleted.
Oops, something went wrong.
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,46 @@ | ||
import { createContext, useContext, useState } from 'react'; | ||
import LoginModal from '@/features/auth/components/LoginModal'; | ||
import useModal from '@/shared/components/Modal/hooks/useModal'; | ||
import type { PropsWithChildren } from 'react'; | ||
|
||
interface LoginPopUpContextProps { | ||
popupLoginModal: (errorCode: number) => void; | ||
} | ||
|
||
const LoginPopUpContext = createContext<LoginPopUpContextProps | null>(null); | ||
|
||
export const useLoginPopup = () => { | ||
const contextValue = useContext(LoginPopUpContext); | ||
|
||
if (contextValue === null) throw new Error('AuthContext가 null입니다.'); | ||
|
||
return contextValue; | ||
}; | ||
|
||
const LoginPopupProvider = ({ children }: PropsWithChildren) => { | ||
const { isOpen, closeModal, openModal } = useModal(false); | ||
const [message, setMessage] = useState('로그인 하시겠습니까?'); | ||
|
||
const popupLoginModal = (errorCode: number) => { | ||
// accessToken 관련 에러 코드 | ||
if ([1000, 1003, 1004].includes(errorCode)) { | ||
setMessage('로그인 정보가 부정확하여 재로그인이 필요합니다.\n다시 로그인하시겠습니까?'); | ||
} | ||
// refreshToken 관련 에러 코드 | ||
if ([1011, 1012, 1007].includes(errorCode)) { | ||
setMessage('로그인 정보가 만료되었습니다.\n다시 로그인하시겠습니까?'); | ||
} | ||
|
||
setMessage('로그인 하시겠습니까?'); | ||
openModal(); | ||
}; | ||
|
||
return ( | ||
<LoginPopUpContext.Provider value={{ popupLoginModal }}> | ||
{children} | ||
<LoginModal isOpen={isOpen} closeModal={closeModal} message={message} /> | ||
</LoginPopUpContext.Provider> | ||
); | ||
}; | ||
|
||
export default LoginPopupProvider; |
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
Oops, something went wrong.