1- import { useEffect , useState } from 'react' ;
1+ import { useEffect } from 'react' ;
22import { useNavigate } from 'react-router' ;
33
44import { getUserToken } from '@/apis/auth' ;
55import useAuthStore from '@/stores/authStore' ;
66
77const AuthCallbackPage = ( ) => {
88 const stateToken = new URLSearchParams ( window . location . search ) . get ( 'state' ) ;
9- const { setUserId, setZipCode, setAccessToken, zipCode } = useAuthStore . getState ( ) ;
10- const [ role , setRole ] = useState < string > ( '' ) ;
9+ const redirectURL = new URLSearchParams ( window . location . search ) . get ( 'redirect' ) ;
10+
11+ const { setUserId, setZipCode, setAccessToken, zipCode } = useAuthStore ( ) ;
1112
1213 const navigate = useNavigate ( ) ;
1314
@@ -18,9 +19,7 @@ const AuthCallbackPage = () => {
1819
1920 const accessToken = userInfo . match ( / B e a r e r \s + ( \S + ) / ) ;
2021 if ( accessToken ) setAccessToken ( accessToken [ 1 ] ) ;
21-
22- const role = userInfo . match ( / R o l e = ( [ \w - ] + ) / ) ;
23- if ( role ) setRole ( role ) ;
22+ console . log ( 'token' , accessToken ) ;
2423
2524 const userId = userInfo . match ( / U s e r I d = ( \d + ) / ) ;
2625 if ( userId ) setUserId ( userId [ 1 ] ) ;
@@ -32,19 +31,18 @@ const AuthCallbackPage = () => {
3231 }
3332 } ;
3433
35- const redirection = ( ) => {
36- if ( role === 'admin' ) navigate ( '/report' ) ;
37- else {
38- if ( ! zipCode ) navigate ( '/onboarding' ) ;
39- else navigate ( '/' ) ;
40- }
41- } ;
34+ // const redirection = () => {
35+ // if(redirectURL === 'onboarding') navigate('/onboarding');
36+ // else if(redirectURL === 'home') navigate('/');
37+ // else navigate('/notFound');
38+ // };
4239
4340 useEffect ( ( ) => {
4441 if ( stateToken ) {
4542 setUserInfo ( stateToken as string ) ;
46- redirection ( ) ;
47- } else navigate ( '/notFound' ) ;
43+ // redirection();
44+ }
45+ // else navigate('/notFound');
4846 } , [ ] ) ;
4947 return < div > </ div > ;
5048} ;
0 commit comments