앱 브릿지 토큰 요청 및 로그아웃 기능 추가
- requestToken 함수 구현 및 토큰 저장 로직 추가 - 토큰 null 체크 및 자동 로그아웃 처리 - 환경 변수 및 빌드 설정 업데이트 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
VITE_APP_ENV=production
|
VITE_APP_ENV=production
|
||||||
VITE_APP_AUTH_PROXY_HOST='http://3.35.79.250:8090'
|
VITE_APP_AUTH_PROXY_HOST='http://3.35.79.250:8090'
|
||||||
VITE_APP_API_PROXY_HOST='http://3.35.79.250:8080'
|
VITE_APP_API_PROXY_HOST='http://3.35.79.250:8080'
|
||||||
# VITE_APP_AUTH_PROXY_HOST='http://auth.nicepay.co.kr'
|
# VITE_APP_AUTH_PROXY_HOST='http://auth.nicepay.co.kr'
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ FROM httpd:2.4-alpine AS production
|
|||||||
RUN apk add --no-cache bash
|
RUN apk add --no-cache bash
|
||||||
|
|
||||||
# Copy built application from builder stage
|
# Copy built application from builder stage
|
||||||
COPY --from=builder /app/dist /usr/local/apache2/htdocs/
|
COPY --from=builder /app/build /usr/local/apache2/htdocs/
|
||||||
|
|
||||||
# Copy Apache configuration
|
# Copy Apache configuration
|
||||||
COPY docker/apache.conf /usr/local/apache2/conf/httpd.conf
|
COPY docker/apache.conf /usr/local/apache2/conf/httpd.conf
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="ko">
|
<html lang="ko">
|
||||||
<head>
|
<head>
|
||||||
|
<title>나이스가맹점관리자</title>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
|
||||||
<title>나이스가맹점관리자</title>
|
|
||||||
<!--파비콘-->
|
<!--파비콘-->
|
||||||
<link rel="shortcut icon" href="src/shared/ui/assets/images/favicon.ico">
|
<link rel="shortcut icon" href="src/shared/ui/assets/images/favicon.ico">
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="src/shared/ui/assets/images/apple-icon-180x180.png">
|
<link rel="apple-touch-icon" sizes="180x180" href="src/shared/ui/assets/images/apple-icon-180x180.png">
|
||||||
|
|||||||
@@ -16,12 +16,11 @@ const initApp = async () => {
|
|||||||
(async () => {
|
(async () => {
|
||||||
await initApp();
|
await initApp();
|
||||||
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
|
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
|
||||||
|
|
||||||
root.render(
|
root.render(
|
||||||
<React.StrictMode>
|
|
||||||
<AppProvider>
|
<AppProvider>
|
||||||
<App />
|
<App />
|
||||||
</AppProvider>
|
</AppProvider>
|
||||||
</React.StrictMode>,
|
|
||||||
);
|
);
|
||||||
// If you want to start measuring performance in your app, pass a function
|
// If you want to start measuring performance in your app, pass a function
|
||||||
// to log results (for example: reportWebVitals(console.log))
|
// to log results (for example: reportWebVitals(console.log))
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import {
|
|||||||
|
|
||||||
export const HomePage = () => {
|
export const HomePage = () => {
|
||||||
const { callLogin } = useUserInfo();
|
const { callLogin } = useUserInfo();
|
||||||
const { openBiometricRegistrationPopup } = useAppBridge();
|
const { isNativeEnvironment, openBiometricRegistrationPopup, requestToken, logout } = useAppBridge();
|
||||||
useSetHeaderTitle('');
|
useSetHeaderTitle('');
|
||||||
useSetHeaderType(HeaderType.Home);
|
useSetHeaderType(HeaderType.Home);
|
||||||
useSetFooterMode(true);
|
useSetFooterMode(true);
|
||||||
@@ -41,6 +41,51 @@ export const HomePage = () => {
|
|||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const handleRequestToken = useCallback(async () =>{
|
||||||
|
console.log('handleRequestToken');
|
||||||
|
alert('handleRequestToken');
|
||||||
|
requestToken()
|
||||||
|
.then((token) => {
|
||||||
|
if (!token) {
|
||||||
|
// 토큰이 null인 경우 로그아웃 처리
|
||||||
|
console.error('Token is null, performing logout');
|
||||||
|
useStore.getState().UserStore.resetUserInfo();
|
||||||
|
setLoginSuccess(false);
|
||||||
|
logout();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log('token', token);
|
||||||
|
|
||||||
|
setLocalStorage(StorageKeys.Usrid, token.usrid);
|
||||||
|
setLocalStorage(StorageKeys.TokenType, token.tokenType);
|
||||||
|
setLocalStorage(StorageKeys.AccessToken, token.accessToken);
|
||||||
|
setLocalStorage(StorageKeys.RefreshToken, token.refreshToken);
|
||||||
|
setLocalStorage(StorageKeys.AccessTokenExpiresIn, token.accessTokenExpiresIn);
|
||||||
|
setLocalStorage(StorageKeys.RefreshTokenExpiresIn, token.refreshTokenExpiresIn);
|
||||||
|
setLocalStorage(StorageKeys.MenuGrants, token.menuGrants);
|
||||||
|
|
||||||
|
useStore.getState().UserStore.setUserInfo({
|
||||||
|
usrid: token.usrid,
|
||||||
|
tokenType: token.tokenType,
|
||||||
|
accessToken: token.accessToken,
|
||||||
|
refreshToken: token.refreshToken,
|
||||||
|
accessTokenExpiresIn: token.accessTokenExpiresIn,
|
||||||
|
refreshTokenExpiresIn: token.refreshTokenExpiresIn,
|
||||||
|
menuGrants: token.menuGrants,
|
||||||
|
});
|
||||||
|
|
||||||
|
setLoginSuccess(true);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
// 토큰 요청 실패 시 로그아웃 처리
|
||||||
|
console.error('Failed to request token:', error);
|
||||||
|
useStore.getState().UserStore.resetUserInfo();
|
||||||
|
setLoginSuccess(false);
|
||||||
|
logout();
|
||||||
|
});
|
||||||
|
|
||||||
|
}, []);
|
||||||
|
|
||||||
const userParmas = {
|
const userParmas = {
|
||||||
id: 'nictest00',
|
id: 'nictest00',
|
||||||
password: 'nictest00'
|
password: 'nictest00'
|
||||||
@@ -48,7 +93,7 @@ export const HomePage = () => {
|
|||||||
|
|
||||||
const handleLogin = useCallback(async () =>{
|
const handleLogin = useCallback(async () =>{
|
||||||
//let appStart = getLocalStorage(StorageKeys.AppStart);
|
//let appStart = getLocalStorage(StorageKeys.AppStart);
|
||||||
|
alert('handleLogin');
|
||||||
//if(!!appStart){
|
//if(!!appStart){
|
||||||
if(false){
|
if(false){
|
||||||
useStore.getState().UserStore.resetUserInfo();
|
useStore.getState().UserStore.resetUserInfo();
|
||||||
@@ -80,6 +125,7 @@ export const HomePage = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const checkBottomBannerOpen = () => {
|
const checkBottomBannerOpen = () => {
|
||||||
|
console.log('checkBottomBannerOpen');
|
||||||
if(!!bannerToday){
|
if(!!bannerToday){
|
||||||
bannerToday = bannerToday.toString();
|
bannerToday = bannerToday.toString();
|
||||||
}
|
}
|
||||||
@@ -92,7 +138,7 @@ export const HomePage = () => {
|
|||||||
setAuthRegisterOn(true);
|
setAuthRegisterOn(true);
|
||||||
}
|
}
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
console.log('catch')
|
console.log('catch', e)
|
||||||
|
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
console.log('finally')
|
console.log('finally')
|
||||||
@@ -102,7 +148,17 @@ export const HomePage = () => {
|
|||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
handleLogin();
|
// handleRequestToken();
|
||||||
|
if (isNativeEnvironment) {
|
||||||
|
alert('isNativeEnvironment');
|
||||||
|
console.log('isNativeEnvironment');
|
||||||
|
handleRequestToken();
|
||||||
|
} else {
|
||||||
|
alert('not isNativeEnvironment');
|
||||||
|
console.log('not isNativeEnvironment');
|
||||||
|
handleLogin();
|
||||||
|
}
|
||||||
|
|
||||||
checkBottomBannerOpen();
|
checkBottomBannerOpen();
|
||||||
checkAuthRegisterOpen();
|
checkAuthRegisterOpen();
|
||||||
}, []);
|
}, []);
|
||||||
@@ -133,7 +189,7 @@ export const HomePage = () => {
|
|||||||
<div className="tab-content blue">
|
<div className="tab-content blue">
|
||||||
<div className="tab-pane dashboard active">
|
<div className="tab-pane dashboard active">
|
||||||
<FavoriteWrapper></FavoriteWrapper>
|
<FavoriteWrapper></FavoriteWrapper>
|
||||||
{ !!loginSuccess &&
|
{ loginSuccess &&
|
||||||
<DayStatusBox></DayStatusBox>
|
<DayStatusBox></DayStatusBox>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ const onResponseRejected = (error: AxiosError) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const initAxios = () => {
|
export const initAxios = () => {
|
||||||
axios.defaults.withCredentials = true;
|
axios.defaults.withCredentials = false;
|
||||||
axios.defaults.timeout = 15000;
|
axios.defaults.timeout = 15000;
|
||||||
axios.defaults.transitional = {
|
axios.defaults.transitional = {
|
||||||
clarifyTimeoutError: true,
|
clarifyTimeoutError: true,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const getAPIBaseUrl = () => {
|
|||||||
}
|
}
|
||||||
return rs;
|
return rs;
|
||||||
};
|
};
|
||||||
const getAPIAuthBaseUrl = () => {
|
const getAPIAuthBaseUrl = () => {
|
||||||
let rs = CURRENT_URL;
|
let rs = CURRENT_URL;
|
||||||
console.log('VITE_APP_ENV : ', import.meta.env.VITE_APP_ENV);
|
console.log('VITE_APP_ENV : ', import.meta.env.VITE_APP_ENV);
|
||||||
if(import.meta.env.VITE_APP_ENV === 'production'){
|
if(import.meta.env.VITE_APP_ENV === 'production'){
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export default ({ mode }) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
esbuild: {
|
esbuild: {
|
||||||
drop: ['console'],
|
drop: [],
|
||||||
},
|
},
|
||||||
plugins: plugins,
|
plugins: plugins,
|
||||||
server: {
|
server: {
|
||||||
|
|||||||
Reference in New Issue
Block a user