Skip to content

Commit 83d6146

Browse files
committed
Merge branch 'develop'
2 parents 8424bfd + a0f874d commit 83d6146

File tree

3 files changed

+21
-26
lines changed

3 files changed

+21
-26
lines changed

src/App.tsx

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,12 @@
1-
import React, { useEffect } from 'react';
1+
import { useEffect } from 'react';
22
import { Router } from './Router';
33
import { StyledProvider } from '@team-aliens/design-system';
4-
import { setCookie } from './utils/cookies';
4+
import { registerSetAuthToken } from './utils/setAuthToken';
55

6-
// ✅ window에 함수 등록
7-
window.setAuthToken = (accessToken: string, refreshToken: string) => {
8-
const expires = new Date();
9-
expires.setDate(expires.getDate() + 7);
10-
11-
if (accessToken) {
12-
setCookie('access_token', accessToken, {
13-
path: '/',
14-
expires,
15-
});
16-
}
17-
if (refreshToken) {
18-
setCookie('refresh_token', refreshToken, {
19-
path: '/',
20-
expires,
21-
});
22-
}
23-
24-
// ✅ 페이지 새로고침
25-
window.location.reload();
26-
return 'SUCCESS';
27-
};
6+
registerSetAuthToken();
287

298
function App() {
309
useEffect(() => {
31-
// ✅ 네이티브(Android 웹뷰)에게 함수 등록 완료됐다고 알려주기
3210
if (window.ReactNativeWebView?.postMessage) {
3311
window.ReactNativeWebView.postMessage('setAuthTokenReady');
3412
}

src/pages/Volunteer/Application.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ enum THEME {
1212
}
1313

1414
export const VolunteerApplication = () => {
15-
console.log('BASE_URL 확인용:', process.env.REACT_APP_BASE_URL);
1615
const location = useLocation();
1716
const initTheme = new URLSearchParams(location.search);
1817
const [userTheme] = useState<THEME>(

src/utils/setAuthToken.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { setCookie } from './cookies';
2+
3+
export function registerSetAuthToken() {
4+
window.setAuthToken = (accessToken: string, refreshToken: string) => {
5+
const expires = new Date();
6+
expires.setDate(expires.getDate() + 7);
7+
8+
if (accessToken) {
9+
setCookie('access_token', accessToken, { path: '/', expires });
10+
}
11+
if (refreshToken) {
12+
setCookie('refresh_token', refreshToken, { path: '/', expires });
13+
}
14+
15+
window.location.reload();
16+
return 'SUCCESS';
17+
};
18+
}

0 commit comments

Comments
 (0)