remove authToken passing in redux thunks

This commit is contained in:
dongfang committed 2025-02-18 04:56:26 +00:00
1 parent 9e0532baf1
commit 6a1e5532e4
5 files changed
+45 -122

No files matched your search

+2 -6
View File
@@ -44,7 +44,7 @@ export const login = createAsyncThunk("auth/login", async (form, thunkApi) => {
});
export const update = createAsyncThunk("auth/update", async (data, thunkApi) => {
const { authToken: token, localData: form } = data;
const { localData: form } = data;
const user = jwtDecode(token);
try {
const fd = new FormData();
@@ -61,7 +61,6 @@ export const update = createAsyncThunk("auth/update", async (data, thunkApi) =>
form.deleteProfileImage && fd.append("deleteProfileImage", form.deleteProfileImage);
const res = await networkService.updateUser({
authToken: token,
userId: user._id,
form: fd,
});
@@ -82,10 +81,7 @@ export const deleteUser = createAsyncThunk("auth/delete", async (data, thunkApi)
const user = jwtDecode(data);
try {
const res = await networkService.deleteUser({
authToken: data,
userId: user._id,
});
const res = await networkService.deleteUser({ userId: user._id, });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -12,11 +12,8 @@ export const createInfrastructureMonitor = createAsyncThunk(
"infrastructureMonitors/createMonitor",
async (data, thunkApi) => {
try {
const { authToken, monitor } = data;
const res = await networkService.createMonitor({
authToken: authToken,
monitor: monitor,
});
const { monitor } = data;
const res = await networkService.createMonitor({ monitor: monitor });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -35,12 +32,8 @@ export const checkInfrastructureEndpointResolution = createAsyncThunk(
"infrastructureMonitors/CheckEndpoint",
async (data, thunkApi) => {
try {
const { authToken, monitorURL } = data;
const res = await networkService.checkEndpointResolution({
authToken: authToken,
monitorURL: monitorURL,
});
const { monitorURL } = data;
const res = await networkService.checkEndpointResolution({ monitorURL: monitorURL, });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -59,11 +52,8 @@ export const getInfrastructureMonitorById = createAsyncThunk(
"infrastructureMonitors/getMonitorById",
async (data, thunkApi) => {
try {
const { authToken, monitorId } = data;
const res = await networkService.getMonitorById({
authToken: authToken,
monitorId: monitorId,
});
const { monitorId } = data;
const res = await networkService.getMonitorById({ monitorId: monitorId });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -84,7 +74,6 @@ export const getInfrastructureMonitorsByTeamId = createAsyncThunk(
const user = jwtDecode(token);
try {
const res = await networkService.getMonitorsAndSummaryByTeamId({
authToken: token,
teamId: user.teamId,
types: ["hardware"],
limit: 1,
@@ -108,7 +97,7 @@ export const updateInfrastructureMonitor = createAsyncThunk(
"infrastructureMonitors/updateMonitor",
async (data, thunkApi) => {
try {
const { authToken, monitor } = data;
const { monitor } = data;
const updatedFields = {
name: monitor.name,
description: monitor.description,
@@ -117,7 +106,6 @@ export const updateInfrastructureMonitor = createAsyncThunk(
threshold: monitor.threshold,
};
const res = await networkService.updateMonitor({
authToken: authToken,
monitorId: monitor._id,
updatedFields: updatedFields,
});
@@ -139,11 +127,8 @@ export const deleteInfrastructureMonitor = createAsyncThunk(
"infrastructureMonitors/deleteMonitor",
async (data, thunkApi) => {
try {
const { authToken, monitor } = data;
const res = await networkService.deleteMonitorById({
authToken: authToken,
monitorId: monitor._id,
});
const { monitor } = data;
const res = await networkService.deleteMonitorById({ monitorId: monitor._id, });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -162,11 +147,8 @@ export const pauseInfrastructureMonitor = createAsyncThunk(
"infrastructureMonitors/pauseMonitor",
async (data, thunkApi) => {
try {
const { authToken, monitorId } = data;
const res = await networkService.pauseMonitorById({
authToken: authToken,
monitorId: monitorId,
});
const { monitorId } = data;
const res = await networkService.pauseMonitorById({ monitorId: monitorId, });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -185,11 +167,8 @@ export const deleteInfrastructureMonitorChecksByTeamId = createAsyncThunk(
"infrastructureMonitors/deleteChecksByTeamId",
async (data, thunkApi) => {
try {
const { authToken, teamId } = data;
const res = await networkService.deleteChecksByTeamId({
authToken: authToken,
teamId: teamId,
});
const { teamId } = data;
const res = await networkService.deleteChecksByTeamId({ teamId: teamId, });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -208,10 +187,7 @@ export const deleteAllInfrastructureMonitors = createAsyncThunk(
"infrastructureMonitors/deleteAllMonitors",
async (data, thunkApi) => {
try {
const { authToken } = data;
const res = await networkService.deleteAllMonitors({
authToken: authToken,
});
const res = await networkService.deleteAllMonitors();
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -12,11 +12,8 @@ export const createPageSpeed = createAsyncThunk(
"pageSpeedMonitors/createPageSpeed",
async (data, thunkApi) => {
try {
const { authToken, monitor } = data;
const res = await networkService.createMonitor({
authToken: authToken,
monitor: monitor,
});
const { monitor } = data;
const res = await networkService.createMonitor({ monitor: monitor, });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -35,12 +32,8 @@ export const checkEndpointResolution = createAsyncThunk(
"monitors/checkEndpoint",
async (data, thunkApi) => {
try {
const { authToken, monitorURL } = data;
const res = await networkService.checkEndpointResolution({
authToken: authToken,
monitorURL: monitorURL,
});
const { monitorURL } = data;
const res = await networkService.checkEndpointResolution({ monitorURL: monitorURL, });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -59,11 +52,8 @@ export const getPagespeedMonitorById = createAsyncThunk(
"monitors/getMonitorById",
async (data, thunkApi) => {
try {
const { authToken, monitorId } = data;
const res = await networkService.getMonitorById({
authToken: authToken,
monitorId: monitorId,
});
const { monitorId } = data;
const res = await networkService.getMonitorById({ monitorId: monitorId, });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -84,7 +74,6 @@ export const getPageSpeedByTeamId = createAsyncThunk(
const user = jwtDecode(token);
try {
const res = await networkService.getMonitorsAndSummaryByTeamId({
authToken: token,
teamId: user.teamId,
types: ["pagespeed"],
});
@@ -106,7 +95,7 @@ export const updatePageSpeed = createAsyncThunk(
"pageSpeedMonitors/updatePageSpeed",
async (data, thunkApi) => {
try {
const { authToken, monitor } = data;
const { monitor } = data;
const updatedFields = {
name: monitor.name,
description: monitor.description,
@@ -114,7 +103,6 @@ export const updatePageSpeed = createAsyncThunk(
// notifications: monitor.notifications,
};
const res = await networkService.updateMonitor({
authToken: authToken,
monitorId: monitor._id,
updatedFields: updatedFields,
});
@@ -136,11 +124,8 @@ export const deletePageSpeed = createAsyncThunk(
"pageSpeedMonitors/deletePageSpeed",
async (data, thunkApi) => {
try {
const { authToken, monitor } = data;
const res = await networkService.deleteMonitorById({
authToken: authToken,
monitorId: monitor._id,
});
const { monitor } = data;
const res = await networkService.deleteMonitorById({ monitorId: monitor._id, });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -158,11 +143,8 @@ export const pausePageSpeed = createAsyncThunk(
"pageSpeedMonitors/pausePageSpeed",
async (data, thunkApi) => {
try {
const { authToken, monitorId } = data;
const res = await networkService.pauseMonitorById({
authToken: authToken,
monitorId: monitorId,
});
const { monitorId } = data;
const res = await networkService.pauseMonitorById({ monitorId: monitorId, });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
+3 -8
View File
@@ -11,9 +11,7 @@ export const getAppSettings = createAsyncThunk(
"settings/getSettings",
async (data, thunkApi) => {
try {
const res = await networkService.getAppSettings({
authToken: data.authToken,
});
const res = await networkService.getAppSettings();
return res.data;
} catch (error) {
if (error.response.data) {
@@ -30,7 +28,7 @@ export const getAppSettings = createAsyncThunk(
export const updateAppSettings = createAsyncThunk(
"settings/updateSettings",
async ({ settings, authToken }, thunkApi) => {
async ({ settings }, thunkApi) => {
networkService.setBaseUrl(settings.apiBaseUrl);
try {
const parsedSettings = {
@@ -49,10 +47,7 @@ export const updateAppSettings = createAsyncThunk(
systemEmailAddress: settings.systemEmailAddress,
systemEmailPassword: settings.systemEmailPassword,
};
const res = await networkService.updateAppSettings({
settings: parsedSettings,
authToken,
});
const res = await networkService.updateAppSettings({ settings: parsedSettings, });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -12,11 +12,8 @@ export const createUptimeMonitor = createAsyncThunk(
"monitors/createMonitor",
async (data, thunkApi) => {
try {
const { authToken, monitor } = data;
const res = await networkService.createMonitor({
authToken: authToken,
monitor: monitor,
});
const { monitor } = data;
const res = await networkService.createMonitor({ monitor: monitor });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -35,12 +32,8 @@ export const checkEndpointResolution = createAsyncThunk(
"monitors/checkEndpoint",
async (data, thunkApi) => {
try {
const { authToken, monitorURL } = data;
const res = await networkService.checkEndpointResolution({
authToken: authToken,
monitorURL: monitorURL,
});
const { monitorURL } = data;
const res = await networkService.checkEndpointResolution({ monitorURL: monitorURL, });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -59,11 +52,8 @@ export const getUptimeMonitorById = createAsyncThunk(
"monitors/getMonitorById",
async (data, thunkApi) => {
try {
const { authToken, monitorId } = data;
const res = await networkService.getMonitorById({
authToken: authToken,
monitorId: monitorId,
});
const { monitorId } = data;
const res = await networkService.getMonitorById({ monitorId: monitorId, });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -82,7 +72,7 @@ export const updateUptimeMonitor = createAsyncThunk(
"monitors/updateMonitor",
async (data, thunkApi) => {
try {
const { authToken, monitor } = data;
const { monitor } = data;
const updatedFields = {
name: monitor.name,
description: monitor.description,
@@ -93,7 +83,6 @@ export const updateUptimeMonitor = createAsyncThunk(
jsonPath: monitor.jsonPath,
};
const res = await networkService.updateMonitor({
authToken: authToken,
monitorId: monitor._id,
monitor,
});
@@ -115,11 +104,8 @@ export const deleteUptimeMonitor = createAsyncThunk(
"monitors/deleteMonitor",
async (data, thunkApi) => {
try {
const { authToken, monitor } = data;
const res = await networkService.deleteMonitorById({
authToken: authToken,
monitorId: monitor._id,
});
const { monitor } = data;
const res = await networkService.deleteMonitorById({ monitorId: monitor._id, });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -138,11 +124,8 @@ export const pauseUptimeMonitor = createAsyncThunk(
"monitors/pauseMonitor",
async (data, thunkApi) => {
try {
const { authToken, monitorId } = data;
const res = await networkService.pauseMonitorById({
authToken: authToken,
monitorId: monitorId,
});
const { monitorId } = data;
const res = await networkService.pauseMonitorById({ monitorId: monitorId, });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -161,11 +144,8 @@ export const deleteMonitorChecksByTeamId = createAsyncThunk(
"monitors/deleteChecksByTeamId",
async (data, thunkApi) => {
try {
const { authToken, teamId } = data;
const res = await networkService.deleteChecksByTeamId({
authToken: authToken,
teamId: teamId,
});
const { teamId } = data;
const res = await networkService.deleteChecksByTeamId({ teamId: teamId, });
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -183,10 +163,7 @@ export const addDemoMonitors = createAsyncThunk(
"monitors/addDemoMonitors",
async (data, thunkApi) => {
try {
const { authToken } = data;
const res = await networkService.addDemoMonitors({
authToken: authToken,
});
const res = await networkService.addDemoMonitors();
return res.data;
} catch (error) {
if (error.response && error.response.data) {
@@ -205,10 +182,7 @@ export const deleteAllMonitors = createAsyncThunk(
"monitors/deleteAllMonitors",
async (data, thunkApi) => {
try {
const { authToken } = data;
const res = await networkService.deleteAllMonitors({
authToken: authToken,
});
const res = await networkService.deleteAllMonitors();
return res.data;
} catch (error) {
if (error.response && error.response.data) {