@@ -7,7 +7,12 @@ import { useLoginMutation } from "@/data/users/postUserLogin/mutation";
77import { safeLocalStorage } from "@/lib/storage" ;
88import { LoadingWithLayout } from "@/shared/components/LoadingWithLayout" ;
99import { PATH } from "@/shared/constants/path" ;
10- import { IS_LOGINED , SOCIAL_LOGIN_TYPE_KEY , TOKEN_KEY } from "@/shared/constants/storage" ;
10+ import {
11+ IS_LOGINED ,
12+ REDIRECT_URL_KEY ,
13+ SOCIAL_LOGIN_TYPE_KEY ,
14+ TOKEN_KEY ,
15+ } from "@/shared/constants/storage" ;
1116import { REDIRECT_URI } from "@/shared/hooks/useOAuth/constants" ;
1217import { SocialLoginType } from "@/shared/hooks/useOAuth/types" ;
1318
@@ -27,6 +32,7 @@ const AuthPage = () => {
2732 const authorizationCode = searchParams . get ( "code" ) ;
2833
2934 const socialType = safeLocalStorage . get ( SOCIAL_LOGIN_TYPE_KEY ) as SocialLoginType ;
35+ const redirectUrl = safeLocalStorage . get ( REDIRECT_URL_KEY ) ;
3036
3137 const { mutateAsync } = useLoginMutation ( ) ;
3238
@@ -40,8 +46,8 @@ const AuthPage = () => {
4046 } ) ;
4147 safeLocalStorage . set ( IS_LOGINED , "true" ) ;
4248
43- // TODO: redirect 로직 구체적으로 추가
44- router . replace ( PATH . HOME ) ;
49+ router . replace ( redirectUrl || PATH . HOME ) ;
50+ safeLocalStorage . remove ( REDIRECT_URL_KEY ) ;
4551 } catch ( error ) {
4652 safeLocalStorage . set ( TOKEN_KEY , ( error as Error ) . message ) ;
4753 router . replace ( PATH . SIGNUP ) ;
@@ -50,7 +56,7 @@ const AuthPage = () => {
5056 // 인증 코드가 없는 경우 로그인 페이지로 리다이렉트
5157 router . replace ( PATH . LOGIN ) ;
5258 }
53- } , [ authorizationCode , mutateAsync , router , socialType ] ) ;
59+ } , [ authorizationCode , mutateAsync , router , socialType , redirectUrl ] ) ;
5460
5561 useEffect ( ( ) => {
5662 handleLogin ( ) ;
0 commit comments