From 008d743faaaf3e0b133781e39634df24978bb5be Mon Sep 17 00:00:00 2001 From: yoosaemsol Date: Tue, 13 Jul 2021 13:21:28 +0900 Subject: [PATCH 1/2] remove withCredentials when fetch data --- console/src/components/DashboardNavbar.js | 8 ++------ console/src/components/common/authCheck.js | 1 - console/src/components/overview/AgentOverview.js | 10 ++-------- console/src/components/overview/TaskOverview.js | 10 ++-------- console/src/components/settings/SettingsPassword.js | 5 +---- console/src/components/task/AllTasks.js | 10 ++-------- console/src/components/task/OrderList.js | 10 ++-------- console/src/components/task/SchedulerList.js | 10 ++-------- console/src/components/zones/AllZones.js | 7 +------ console/src/pages/Activate.js | 5 +---- console/src/pages/Login.js | 9 ++------- console/src/pages/ZoneList.js | 9 ++------- 12 files changed, 19 insertions(+), 75 deletions(-) diff --git a/console/src/components/DashboardNavbar.js b/console/src/components/DashboardNavbar.js index 0c93b3c..cded02c 100644 --- a/console/src/components/DashboardNavbar.js +++ b/console/src/components/DashboardNavbar.js @@ -36,9 +36,7 @@ const Zone = () => { useEffect(() => { let completed = false; async function get() { - const result = await axios.get(`${API_SERVER}/inner/groups`, { - withCredentials: true - }); + const result = await axios.get(`${API_SERVER}/inner/groups`); if (!completed) setData(result.data); dispatch(filterByZone(result.data[0].Id)); } @@ -83,9 +81,7 @@ const DashboardNavbar = ({ onMobileNavOpen, ...rest }) => { const signOutHandler = () => { async function signOut() { - const result = await axios.get(`${API_SERVER}/console/signout`, { - withCredentials: true - }); + const result = await axios.get(`${API_SERVER}/console/signout`); console.log(result.status === 200); if (result.status === 200) { navigate('/login', { replace: true }); diff --git a/console/src/components/common/authCheck.js b/console/src/components/common/authCheck.js index 3caa9f1..621ad2c 100644 --- a/console/src/components/common/authCheck.js +++ b/console/src/components/common/authCheck.js @@ -3,7 +3,6 @@ import axios, { Method } from 'axios'; export const baseURL = process.env.REACT_APP_API_URL; export const request = axios.create({ - withCredentials: true, baseURL }); diff --git a/console/src/components/overview/AgentOverview.js b/console/src/components/overview/AgentOverview.js index 3c2f381..6049060 100644 --- a/console/src/components/overview/AgentOverview.js +++ b/console/src/components/overview/AgentOverview.js @@ -33,10 +33,7 @@ const AgentList = () => { async function get() { const result = await axios.get( - `${API_SERVER}/inner/groups/${currentZone}/agents`, - { - withCredentials: true - } + `${API_SERVER}/inner/groups/${currentZone}/agents` ); if (!completed) dispatch(getAgentList(result.data)); } @@ -112,10 +109,7 @@ const AddAgent = () => { async function get() { const result = await axios.get( - `${API_SERVER}/inner/groups/${currentZone}/agents`, - { - withCredentials: true - } + `${API_SERVER}/inner/groups/${currentZone}/agents` ); dispatch(getAgentList(result.data)); diff --git a/console/src/components/overview/TaskOverview.js b/console/src/components/overview/TaskOverview.js index 2e6cd20..95713c3 100644 --- a/console/src/components/overview/TaskOverview.js +++ b/console/src/components/overview/TaskOverview.js @@ -28,10 +28,7 @@ const TaskList = () => { async function get() { const result = await axios.get( - `${API_SERVER}/inner/tasks?groupID=${currentZone}`, - { - withCredentials: true - } + `${API_SERVER}/inner/tasks?groupID=${currentZone}` ); if (!completed) setData(result.data); } @@ -46,10 +43,7 @@ const TaskList = () => { async function get() { const result = await axios.get( - `${API_SERVER}/inner/tasks?groupID=${currentZone}`, - { - withCredentials: true - } + `${API_SERVER}/inner/tasks?groupID=${currentZone}` ); if (!completed) setData(result.data); } diff --git a/console/src/components/settings/SettingsPassword.js b/console/src/components/settings/SettingsPassword.js index 3ad4135..2b74749 100644 --- a/console/src/components/settings/SettingsPassword.js +++ b/console/src/components/settings/SettingsPassword.js @@ -40,10 +40,7 @@ const SettingsPassword = (props) => { const response = await axios.post( `${API_SERVER}/console/changepassword`, form, - { headers }, - { - withCredentials: true - } + { headers } ); console.log(response); diff --git a/console/src/components/task/AllTasks.js b/console/src/components/task/AllTasks.js index 72fd601..b4afeaa 100644 --- a/console/src/components/task/AllTasks.js +++ b/console/src/components/task/AllTasks.js @@ -22,10 +22,7 @@ const TaskList = () => { async function get() { const result = await axios.get( - `${API_SERVER}/inner/tasks?groupID=${currentZone}`, - { - withCredentials: true - } + `${API_SERVER}/inner/tasks?groupID=${currentZone}` ); if (!completed) setData(result.data); } @@ -40,10 +37,7 @@ const TaskList = () => { async function get() { const result = await axios.get( - `${API_SERVER}/inner/tasks?groupID=${currentZone}`, - { - withCredentials: true - } + `${API_SERVER}/inner/tasks?groupID=${currentZone}` ); if (!completed) setData(result.data); } diff --git a/console/src/components/task/OrderList.js b/console/src/components/task/OrderList.js index a90ec3c..4eb9a24 100644 --- a/console/src/components/task/OrderList.js +++ b/console/src/components/task/OrderList.js @@ -22,10 +22,7 @@ const TaskList = () => { async function get() { const result = await axios.get( - `${API_SERVER}/inner/tasks?groupID=${currentZone}`, - { - withCredentials: true - } + `${API_SERVER}/inner/tasks?groupID=${currentZone}` ); if (!completed) setData(result.data); } @@ -40,10 +37,7 @@ const TaskList = () => { async function get() { const result = await axios.get( - `${API_SERVER}/inner/tasks?groupID=${currentZone}`, - { - withCredentials: true - } + `${API_SERVER}/inner/tasks?groupID=${currentZone}` ); if (!completed) setData(result.data); } diff --git a/console/src/components/task/SchedulerList.js b/console/src/components/task/SchedulerList.js index b7287db..123c001 100644 --- a/console/src/components/task/SchedulerList.js +++ b/console/src/components/task/SchedulerList.js @@ -22,10 +22,7 @@ const TaskList = () => { async function get() { const result = await axios.get( - `${API_SERVER}/inner/tasks?groupID=${currentZone}`, - { - withCredentials: true - } + `${API_SERVER}/inner/tasks?groupID=${currentZone}` ); if (!completed) setData(result.data); } @@ -40,10 +37,7 @@ const TaskList = () => { async function get() { const result = await axios.get( - `${API_SERVER}/inner/tasks?groupID=${currentZone}`, - { - withCredentials: true - } + `${API_SERVER}/inner/tasks?groupID=${currentZone}` ); if (!completed) setData(result.data); } diff --git a/console/src/components/zones/AllZones.js b/console/src/components/zones/AllZones.js index 69dba04..6aca3e8 100644 --- a/console/src/components/zones/AllZones.js +++ b/console/src/components/zones/AllZones.js @@ -30,9 +30,7 @@ const TaskList = () => { let completed = false; async function get() { - const result = await axios.get(`${API_SERVER}/inner/groups`, { - withCredentials: true - }); + const result = await axios.get(`${API_SERVER}/inner/groups`); if (!completed) dispatch(getZoneList(result.data)); } get(); @@ -64,9 +62,6 @@ const TaskList = () => { // const response = await axios.delete( // `${API_SERVER}/inner/groups/${id}`, // { headers }, - // { - // withCredentials: true - // } // ); // console.log(response); } diff --git a/console/src/pages/Activate.js b/console/src/pages/Activate.js index 5c27a7b..4deadf5 100644 --- a/console/src/pages/Activate.js +++ b/console/src/pages/Activate.js @@ -48,10 +48,7 @@ const Activate = () => { const response = await axios.post( `${API_SERVER}/console/changepassword`, form, - { headers }, - { - withCredentials: true - } + { headers } ); if (response.status === 200) { diff --git a/console/src/pages/Login.js b/console/src/pages/Login.js index 3d8afe6..5a75cdb 100644 --- a/console/src/pages/Login.js +++ b/console/src/pages/Login.js @@ -23,9 +23,7 @@ const Login = () => { useEffect(() => { async function check() { - const result = await axios.get(`${API_SERVER}/console/activated/admin`, { - withCredentials: true - }); + const result = await axios.get(`${API_SERVER}/console/activated/admin`); if (result.data.status === 'initialized') { navigate('/activate', { replace: true }); @@ -67,10 +65,7 @@ const Login = () => { const response = await axios.post( `${API_SERVER}/console/signin`, form, - { headers }, - { - withCredentials: true - } + { headers } ); response.data.token && diff --git a/console/src/pages/ZoneList.js b/console/src/pages/ZoneList.js index 5a28a37..e3a6265 100644 --- a/console/src/pages/ZoneList.js +++ b/console/src/pages/ZoneList.js @@ -60,18 +60,13 @@ const Dashboard = () => { groupName: groupname, platform: platform }, - { headers }, - { - withCredentials: true - } + { headers } ); console.log(response.status === 200); if (response.status === 200) { async function get() { - const result = await axios.get(`${API_SERVER}/inner/groups`, { - withCredentials: true - }); + const result = await axios.get(`${API_SERVER}/inner/groups`); dispatch(getZoneList(result.data)); } get(); From 05ca889794e4544a4d2ac67ad0c1e47219f76dfb Mon Sep 17 00:00:00 2001 From: yoosaemsol Date: Tue, 13 Jul 2021 13:27:59 +0900 Subject: [PATCH 2/2] Add Zone Deletion --- console/src/components/zones/AllZones.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/console/src/components/zones/AllZones.js b/console/src/components/zones/AllZones.js index 6aca3e8..f51a6d1 100644 --- a/console/src/components/zones/AllZones.js +++ b/console/src/components/zones/AllZones.js @@ -55,15 +55,18 @@ const TaskList = () => { console.log(`delete zone id ${id}`); async function deleteZone() { - // const headers = { - // accept: 'application/json', - // 'Content-Type': 'application/json' - // }; - // const response = await axios.delete( - // `${API_SERVER}/inner/groups/${id}`, - // { headers }, - // ); - // console.log(response); + const headers = { + accept: 'application/json', + 'Content-Type': 'application/json' + }; + const response = await axios.delete( + `${API_SERVER}/inner/groups/${id}`, + { headers } + ); + if (response.status === 200) { + const result = await axios.get(`${API_SERVER}/inner/groups`); + dispatch(getZoneList(result.data)); + } } deleteZone(); },