Skip to content

Commit

Permalink
[Fix]토큰 변수명 통일
Browse files Browse the repository at this point in the history
엑세스 토큰의 변수명 ->accessToken
리프레시 토큰의 변수명 ->refreshToken
전체 파일에 있는 모든 토큰 명을 변환
Issues #15
  • Loading branch information
김병현 authored and 김병현 committed Sep 16, 2023
1 parent 0b45a87 commit f273193
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 73 deletions.
2 changes: 1 addition & 1 deletion client/src/components/CentralChartMenu/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import CompareChartBtn from "./CompareChartBtn";
const UpperMenuBar = () => {
const companyId = useSelector((state: StateProps) => state.companyId);

console.log(localStorage.getItem("authToken"));
console.log(localStorage.getItem("accessToken"));

return (
<Container>
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Headers/LoginHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const LoginHeader: React.FC<LoginHeaderProps> = () => {

const handleLogout = () => {
dispatch(setLogoutState()); // 전역변수에서 로그아웃 상태로 설정
localStorage.removeItem("Authorization"); // 엑세스 토큰 제거
localStorage.removeItem("Refresh-token"); // 리프레시 토큰 제거
localStorage.removeItem("accessToken"); // 엑세스 토큰 제거
localStorage.removeItem("refreshToken"); // 리프레시 토큰 제거
};

return (
Expand Down
8 changes: 4 additions & 4 deletions client/src/components/Logins/EmailLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ const EmailLoginModal: React.FC<EmailLoginModalProps> = ({ onClose, onLogin }) =
password,
});
if (response.status === 200) {
const authToken = response.headers["authorization"];
console.log(authToken);
const accessToken = response.headers["authorization"];
console.log(accessToken);

const refreshToken = response.headers["refresh"];

// 로그인 상태로 만들기
dispatch(setLoginState());

// 토큰들을 로컬 스토리지에 저장
if (authToken) localStorage.setItem("Authorization", authToken);
if (refreshToken) localStorage.setItem("Refresh-token", refreshToken);
if (accessToken) localStorage.setItem("accessToken", accessToken);
if (refreshToken) localStorage.setItem("refreshToken", refreshToken);

onLogin();
onClose();
Expand Down
43 changes: 0 additions & 43 deletions client/src/components/Logins/GoogleSignin.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions client/src/components/Logins/TokenHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const TokenHandler: React.FC = () => {
const refreshToken = urlParams.get("refresh_token");

if (accessToken && refreshToken) {
localStorage.setItem("Authorization", `Bearer ${accessToken}`);
localStorage.setItem("Refresh-token", refreshToken);
localStorage.setItem("accessToken", `Bearer ${accessToken}`);
localStorage.setItem("refreshToken", refreshToken);
dispatch(setLoginState());
navigate('/');
}
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/communityComponents/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const TimeLineComponent = () => {
};

// 서브밋 버튼 클릭
const authToken = localStorage.getItem("authToken");
const accessToken = localStorage.getItem("accessToken");
const handleClickSubmit = async () => {
if (inputValue.length !== 0) {
const newBoardData = {
Expand All @@ -53,7 +53,7 @@ const TimeLineComponent = () => {
try {
const response = await axios.post(serverUrl, newBoardData, {
headers: {
Authorization: authToken, // 토큰을 헤더에 추가
Authorization: accessToken, // 토큰을 헤더에 추가
},
});
if (response.status === 201) {
Expand Down Expand Up @@ -93,7 +93,7 @@ const TimeLineComponent = () => {
try {
const response = await axios.delete(`${serverUrl}/${boardId}`, {
headers: {
Authorization: authToken, // 토큰을 헤더에 추가
Authorization: accessToken, // 토큰을 헤더에 추가
},
}); // URL에 boardId 추가
if (response.status === 200) {
Expand Down
4 changes: 2 additions & 2 deletions client/src/hooks/useCash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import axios from 'axios';
const BASE_URL = 'http://ec2-13-125-246-160.ap-northeast-2.compute.amazonaws.com:8080';

const getAuthHeader = () => {
const authToken = localStorage.getItem('authToken');
const accessToken = localStorage.getItem('accessToken');
return {
'Authorization': `${authToken}`
'Authorization': `${accessToken}`
};

};
Expand Down
4 changes: 2 additions & 2 deletions client/src/hooks/useDeleteStockOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export default useDeleteStockOrder;
const deleteStockOrder = async (orderId: number, cancleVolume: number) => {
const url = `http://ec2-13-125-246-160.ap-northeast-2.compute.amazonaws.com:8080/stock/stockorders?stockOrderId=${orderId}&stockCount=${cancleVolume}`;

const authToken = localStorage.getItem("authToken");
const accessToken = localStorage.getItem("accessToken");
const options = {
headers: {
Authorization: `${authToken}`,
Authorization: `${accessToken}`,
"Content-Type": "application/json",
},
};
Expand Down
4 changes: 2 additions & 2 deletions client/src/hooks/useGetCash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ const useGetCash = () => {
export default useGetCash;

const getCashData = async () => {
const token = localStorage.getItem("Authorization");
const accessToken = localStorage.getItem("accessToken");
const options = {
headers: {
Authorization: `${token}`,
Authorization: `${accessToken}`,
"Content-Type": "application/json",
},
};
Expand Down
4 changes: 2 additions & 2 deletions client/src/hooks/useGetHoldingStock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ const useGetHoldingStock = () => {
export default useGetHoldingStock;

const getHoldingStock = async () => {
const authToken = localStorage.getItem("authToken");
const accessToken = localStorage.getItem("accessToken");
const options = {
headers: {
Authorization: `${authToken}`,
Authorization: `${accessToken}`,
"Content-Type": "application/json",
},
};
Expand Down
6 changes: 3 additions & 3 deletions client/src/hooks/useGetMemberInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import axios from 'axios';

export function useGetMemberInfo() {
return useQuery(['member'], async () => {
const authToken = localStorage.getItem('authToken'); // 로컬 스토리지에서 AuthToken 가져오기
const accessToken = localStorage.getItem('accessToken'); // 로컬 스토리지에서 AuthToken 가져오기

console.log(authToken);
console.log(accessToken);

const response = await axios.get(`http://ec2-13-125-246-160.ap-northeast-2.compute.amazonaws.com:8080/members`, {
headers: {
'Authorization': `${authToken}` // 헤더에 토큰 추가
'Authorization': `${accessToken}` // 헤더에 토큰 추가
}
});

Expand Down
4 changes: 2 additions & 2 deletions client/src/hooks/useGetStockOrderRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ const useGetStockOrderRecord = () => {
export default useGetStockOrderRecord;

const getOrderRecord = async () => {
const authToken = localStorage.getItem("authToken");
const accessToken = localStorage.getItem("accessToken");
const options = {
headers: {
Authorization: `${authToken}`,
Authorization: `${accessToken}`,
"Content-Type": "application/json",
},
};
Expand Down
4 changes: 2 additions & 2 deletions client/src/hooks/useGetStockholds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export default useGetStockHolds;

// 서버에서 StockHolds 목록 fetch 하는 함수
const getStockHolds = async () => {
const token = localStorage.getItem('Authorization'); // 로컬 스토리지에서 토큰 가져오기
const accessToken = localStorage.getItem('accessToken'); // 로컬 스토리지에서 토큰 가져오기
const res = await axios.get("http://ec2-13-125-246-160.ap-northeast-2.compute.amazonaws.com:8080/stock/stockholds", {
headers: {
'Authorization': token
'Authorization': accessToken
}
});
const stockHoldsList = await res.data;
Expand Down
6 changes: 3 additions & 3 deletions client/src/hooks/useTradeStock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ const useTradeStock = () => {
export default useTradeStock;

const postOrderRequest = async (orderType: boolean, companyId: number, price: number, volume: number) => {
const authToken = localStorage.getItem("authToken");
console.log(authToken);
const accessToken = localStorage.getItem("accessToken");
console.log(accessToken);
const options = {
headers: {
Authorization: `${authToken}`,
Authorization: `${accessToken}`,
"Content-Type": "application/json",
},
};
Expand Down

0 comments on commit f273193

Please sign in to comment.