Skip to content

Commit 560d2a5

Browse files
committed
token solved
1 parent f019b8a commit 560d2a5

15 files changed

+1097
-881
lines changed

.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
NODE_ENV=local
2-
REACT_APP_API_URL = http://localhost:8080
2+
REACT_APP_API_URL = http://210.109.61.100
33
GENERATE_SOURCEMAP = false

.env.development

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
NODE_ENV=development
2-
REACT_APP_API_URL = http://localhost:8080
2+
REACT_APP_API_URL = http://210.109.61.100

nginx.conf

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
server {
22
listen 80;
3-
server_name www.commfy.shop;
43
location / {
54
root /usr/share/nginx/html;
65
index index.html index.htm;

package-lock.json

+832-762
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"redux": "^4.2.0",
3333
"redux-promise": "^0.6.0",
3434
"redux-thunk": "^2.4.1",
35+
"sentry": "^0.1.2",
3536
"styled-components": "^5.3.6",
3637
"web-vitals": "^2.1.4"
3738
},
@@ -43,7 +44,6 @@
4344
"test": "craco test",
4445
"eject": "react-scripts eject"
4546
},
46-
"proxy": "http://210.109.60.160",
4747
"eslintConfig": {
4848
"extends": [
4949
"react-app",

src/components/common/Header.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ const resources = [
5858
}
5959
]
6060

61-
//const clientId="487333198384-nh6ucotf0f9djvv3u6oemopui89d8p7k.apps.googleusercontent.com";
62-
const clientId="150579669124-iuljf351licgh2lg7s35t1fcn9ct6k2h.apps.googleusercontent.com";
61+
const clientId="487333198384-nh6ucotf0f9djvv3u6oemopui89d8p7k.apps.googleusercontent.com";
62+
//const clientId="150579669124-iuljf351licgh2lg7s35t1fcn9ct6k2h.apps.googleusercontent.com";
6363

6464

6565

@@ -76,7 +76,7 @@ function Header() {
7676

7777
useEffect(()=>{
7878
console.log('header memberId is changed',typeof(localStorage.getItem('memberId')));
79-
if(localStorage.getItem('memberId')==='0') {
79+
if(!localStorage.getItem('memberId')) {
8080
setIsLogin(false);
8181
setLogoutAlert(true);
8282
}

src/components/pages/create/CreateSurvey.jsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,13 @@ function Share_modal() {
128128

129129
console.log(survey_data)
130130
CreateSurveyService.saveSurvey(loc,memberid,survey_data).then(response=>{
131+
console.log(response)
131132
if(response.data.result){
132133
setId(response.data.result)
133134
setShare(true)
134135
const surveyId=response.data.result;
135136
postSurveyThumbnail(surveyId);
136137
}
137-
else{
138-
console.log(response.data)
139-
}
140138
})
141139
}
142140

@@ -275,13 +273,14 @@ function CreateSurveySend() {
275273
state["end"]="not"
276274
setDisabled(true)
277275
CreateSurveyService.saveSurvey(loc,memberid,state).then(response=>{
276+
console.log(response)
278277
if(response.data.isSuccess || response.data.isSuccess===undefined){
279278
if(!serverload){
280279
console.log('response',response);
281280
console.log('response data',response.data);
282281
const surveyId=response.data.result;
283282
console.log('after post survey: surveyId - ',surveyId);
284-
postSurveyThumbnail(surveyId);
283+
postSurveyThumbnail(surveyId)
285284
}
286285
navigate(`/temporary`)
287286
}

src/components/pages/create/CreateSurveyTemplates.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function CreateSurveyTemplates() {
1515
return (
1616
<div className="bg-white">
1717
<div className="mx-auto max-w-2xl py-16 px-4 sm:py-6 sm:px-6 lg:max-w-7xl lg:px-8">
18-
<h2 className="text-2xl font-bold tracking-tight text-gray-900"> 설문 진행 중인 설문지</h2>
18+
<h2 className="text-2xl font-bold tracking-tight text-gray-900"> Comfy 설문 템플릿</h2>
1919
{TemplateList.length !== 0 ?
2020
<div className="mt-6 grid grid-cols-1 gap-y-4 gap-x-6 sm:grid-cols-2 lg:grid-cols-4 xl:gap-x-8">
2121
{TemplateList?TemplateList.map((survey) => (

src/modules/member.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import axios from 'axios';
2+
import { useNavigate } from 'react-router-dom';
23
import { logout } from "../services/MemberService";
34

45
const LOGIN_MEMBER='member/LOGIN_MEMBER';
@@ -32,19 +33,18 @@ export function logoutMember(){
3233

3334
// clear localStorage
3435
export function initialize(){
35-
localStorage.setItem('accessToken',null);
36-
localStorage.setItem('refreshToken',null);
37-
localStorage.setItem('memberId',0);
38-
localStorage.setItem('email',null);
39-
localStorage.setItem('name',null);
36+
localStorage.clear()
37+
window.location.replace("/")
4038
//alert('LOGOUT');
4139

4240
}
4341

4442
// reset accessToken by refreshToken
45-
export function renew_accessToken(accessToken){
43+
export function renew_accessToken(accessToken,refreshToken){
4644
console.log('renew accessToken',accessToken);
4745
localStorage.setItem('accessToken',accessToken);
46+
console.log('renew refreshToken',refreshToken);
47+
localStorage.setItem('refreshToken',refreshToken);
4848
}
4949

5050
//모듈 초기 상태

src/services/CreateSurveyService.js

+28-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axios from 'axios';
22
import { useLocation } from 'react-router-dom';
3-
import { renew_accessToken } from '../modules/member';
3+
import { initialize, renew_accessToken } from '../modules/member';
44
import * as Sentry from "@sentry/react";
55

66
const SURVEY_API_BASE_URL = `${process.env.REACT_APP_API_URL}`;
@@ -18,10 +18,15 @@ class SurveyService {
1818
axios.defaults.headers.post = null
1919
const response=await axios.post(`${SURVEY_API_BASE_URL}${loc}/${memberid}`, data,{headers:config}).catch(function(e){
2020
Sentry.captureException(e);
21-
}); //survey/1/1 //Survey/1
22-
console.log(response)
23-
if(response.config.headers.accesstoken){
24-
renew_accessToken(response.config.headers.accesstoken);
21+
})
22+
if(response.headers["auth-token"]){
23+
const auth_token=response.headers["auth-token"].split(';',2)[0].split('=',2)[1]
24+
const access_Token=auth_token.split(":",4)[1]
25+
const refresh_Token=auth_token.split(":",4)[3]
26+
renew_accessToken(access_Token,refresh_Token);
27+
}
28+
if(response.status===401){
29+
initialize()
2530
}
2631
return response
2732
}
@@ -39,18 +44,30 @@ class SurveyService {
3944
value="/load"+value
4045
const response = await axios.get(SURVEY_API_BASE_URL+`${value}`,{headers:config}).catch(function(e){
4146
Sentry.captureException(e);
42-
});
43-
if(response.config.headers.accesstoken){
44-
renew_accessToken(response.config.headers.accesstoken);
47+
})
48+
if(response.headers["auth-token"]){
49+
const auth_token=response.headers["auth-token"].split(';',2)[0].split('=',2)[1]
50+
const access_Token=auth_token.split(":",4)[1]
51+
const refresh_Token=auth_token.split(":",4)[3]
52+
renew_accessToken(access_Token,refresh_Token);
53+
}
54+
if(response.status===401){
55+
initialize()
4556
}
4657
return response
4758
}
4859
async sendSurvey(loc,data){
4960
const response= await axios.post(SURVEY_API_BASE_URL+`${loc}`, data,{headers:config}).catch(function(e){
5061
Sentry.captureException(e);
51-
});
52-
if(response.config.headers.accesstoken){
53-
renew_accessToken(response.config.headers.accesstoken);
62+
})
63+
if(response.headers["auth-token"]){
64+
const auth_token=response.headers["auth-token"].split(';',2)[0].split('=',2)[1]
65+
const access_Token=auth_token.split(":",4)[1]
66+
const refresh_Token=auth_token.split(":",4)[3]
67+
renew_accessToken(access_Token,refresh_Token);
68+
}
69+
if(response.status===401){
70+
initialize()
5471
}
5572
return response
5673
}

src/services/ManageService.js

+56-20
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ const config={
1515
class ManageSurveyService {
1616

1717
async getSurveys(){
18-
const response=await axios.get(MANAGESURVEY_API_BASE_URL+"/surveys",{headers:config}).catch(function(e){
18+
const response=await axios.get(MANAGESURVEY_API_BASE_URL+"/surveys",{config}).catch(function(e){
1919
Sentry.captureException(e);
20-
});
21-
if(response.config.headers.accesstoken){
22-
renew_accessToken(response.config.headers.accesstoken);
20+
})
21+
if(response.headers["auth-token"]){
22+
const auth_token=response.headers["auth-token"].split(';',2)[0].split('=',2)[1]
23+
const access_Token=auth_token.split(":",4)[1]
24+
const refresh_Token=auth_token.split(":",4)[3]
25+
renew_accessToken(access_Token,refresh_Token);
26+
}
27+
if(response.status===401){
28+
initialize()
2329
}
2430
return response;
2531
}
@@ -30,11 +36,17 @@ class ManageSurveyService {
3036
console.log('[updateSurvey] - memberId',memberId);
3137
console.log('[updateSurvey] - accessToken',accessToken);
3238
console.log('[updateSurvey] - refreshToken',refreshToken);
33-
const response=await axios.patch(`/surveys/${surveyId}`,{headers:config}).catch(function(e){
39+
const response=await axios.patch(`/surveys/${surveyId}`,{config}).catch(function(e){
3440
Sentry.captureException(e);
35-
});
36-
if(response.config.headers.accesstoken){
37-
renew_accessToken(response.config.headers.accesstoken);
41+
})
42+
if(response.headers["auth-token"]){
43+
const auth_token=response.headers["auth-token"].split(';',2)[0].split('=',2)[1]
44+
const access_Token=auth_token.split(":",4)[1]
45+
const refresh_Token=auth_token.split(":",4)[3]
46+
renew_accessToken(access_Token,refresh_Token);
47+
}
48+
if(response.status===401){
49+
initialize()
3850
}
3951
return response;
4052
//axios.put(MANAGESURVEY_API_BASE_URL + '/' + surveyId, survey);
@@ -43,9 +55,15 @@ class ManageSurveyService {
4355
async updateSurvey2(surveyId){
4456
const response=await axios.patch(MANAGESURVEY_API_BASE_URL+"/surveys" + '/' + surveyId,{headers:config}).catch(function(e){
4557
Sentry.captureException(e);
46-
});
47-
if(response.config.headers.accesstoken){
48-
renew_accessToken(response.config.headers.accesstoken);
58+
})
59+
if(response.headers["auth-token"]){
60+
const auth_token=response.headers["auth-token"].split(';',2)[0].split('=',2)[1]
61+
const access_Token=auth_token.split(":",4)[1]
62+
const refresh_Token=auth_token.split(":",4)[3]
63+
renew_accessToken(access_Token,refresh_Token);
64+
}
65+
if(response.status===401){
66+
initialize()
4967
}
5068
return response;
5169
}
@@ -54,9 +72,15 @@ class ManageSurveyService {
5472
console.log('manage survey service - memberId',memberId);
5573
const response=await axios.get(`/surveys/${memberId}`,{headers:config}).catch(function(e){
5674
Sentry.captureException(e);
57-
});
58-
if(response.config.headers.accesstoken){
59-
renew_accessToken(response.config.headers.accesstoken);
75+
})
76+
if(response.headers["auth-token"]){
77+
const auth_token=response.headers["auth-token"].split(';',2)[0].split('=',2)[1]
78+
const access_Token=auth_token.split(":",4)[1]
79+
const refresh_Token=auth_token.split(":",4)[3]
80+
renew_accessToken(access_Token,refresh_Token);
81+
}
82+
if(response.status===401){
83+
initialize()
6084
}
6185
return response;
6286
// return axios.get(MANAGESURVEY_API_BASE_URL + '/' + memberId);
@@ -65,19 +89,31 @@ class ManageSurveyService {
6589
async getSurveyByStatus(status){
6690
const response =await axios.get(MANAGESURVEY_API_BASE_URL+"/surveys" + '/' + status+'/'+memberId,{headers:config}).catch(function(e){
6791
Sentry.captureException(e);
68-
});
69-
if(response.config.headers.accesstoken){
70-
renew_accessToken(response.config.headers.accesstoken);
92+
})
93+
if(response.headers["auth-token"]){
94+
const auth_token=response.headers["auth-token"].split(';',2)[0].split('=',2)[1]
95+
const access_Token=auth_token.split(":",4)[1]
96+
const refresh_Token=auth_token.split(":",4)[3]
97+
renew_accessToken(access_Token,refresh_Token);
98+
}
99+
if(response.status===401){
100+
initialize()
71101
}
72102
return response
73103
}
74104

75105
async deleteSurvey(surveyId){
76106
const response=await axios.delete(`${MANAGESURVEY_API_BASE_URL}/surveys/${surveyId}/${memberId}`,{headers:config}).catch(function(e){
77107
Sentry.captureException(e);
78-
});
79-
if(response.config.headers.accesstoken){
80-
renew_accessToken(response.config.headers.accesstoken);
108+
})
109+
if(response.headers["auth-token"]){
110+
const auth_token=response.headers["auth-token"].split(';',2)[0].split('=',2)[1]
111+
const access_Token=auth_token.split(":",4)[1]
112+
const refresh_Token=auth_token.split(":",4)[3]
113+
renew_accessToken(access_Token,refresh_Token);
114+
}
115+
if(response.status===401){
116+
initialize()
81117
}
82118
return response;
83119
}

src/services/MemberService.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import axios from 'axios';
22
import * as Sentry from "@sentry/react";
33

4-
const SURVEY_API_BASE_URL=`${process.env.REACT_APP_API_URL}`
4+
const SURVEY_API_BASE_URL=`${process.env.REACT_APP_API_URL}`;
55
// 구글 로그인
66
export async function login(idToken){
77
console.log('idToken',idToken);
8-
const response=await axios.get(`${SURVEY_API_BASE_URL}/login/google/${idToken}`).then((response)=>{
9-
console.log(response.data.result);
8+
const response=await axios.get(`${SURVEY_API_BASE_URL}/login/google/${idToken}`,{headers: { 'Authorization': 'XXXX' }}).then((response)=>{
9+
console.log(response);
1010
if(response.data.code===2002){
1111
localStorage.clear();
1212
}
@@ -19,7 +19,7 @@ export async function login(idToken){
1919
}
2020
}).catch(function(e){
2121
Sentry.captureException(e);
22-
});
22+
})
2323

2424

2525
}
@@ -30,7 +30,7 @@ export async function logout(){
3030

3131
const response=await axios.delete(`${SURVEY_API_BASE_URL}/logout/${localStorage.getItem('memberId')}`).catch(function(e){
3232
Sentry.captureException(e);
33-
});
33+
})
3434
console.log('logout response',response);
3535

3636
return response;

0 commit comments

Comments
 (0)