separate user from token
This commit is contained in:
1 parent
8747c38f40
commit
af82dec2ad
6 files changed
+19
-28
No files matched your search
@@ -32,7 +32,6 @@ const ActionsMenu = ({
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
let monitor = { id: actions.id };
|
let monitor = { id: actions.id };
|
||||||
console.log(monitor);
|
|
||||||
await deleteMonitor({ monitor });
|
await deleteMonitor({ monitor });
|
||||||
updateRowCallback();
|
updateRowCallback();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,21 +10,24 @@ const initialState = {
|
|||||||
msg: null,
|
msg: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const register = createAsyncThunk("auth/register", async (form, thunkApi) => {
|
export const register = createAsyncThunk(
|
||||||
try {
|
"auth/register",
|
||||||
const res = await networkService.registerUser(form);
|
async ({ user, token }, thunkApi) => {
|
||||||
return res.data;
|
try {
|
||||||
} catch (error) {
|
const res = await networkService.registerUser(user, token);
|
||||||
if (error.response.data) {
|
return res.data;
|
||||||
return thunkApi.rejectWithValue(error.response.data);
|
} catch (error) {
|
||||||
|
if (error.response.data) {
|
||||||
|
return thunkApi.rejectWithValue(error.response.data);
|
||||||
|
}
|
||||||
|
const payload = {
|
||||||
|
status: false,
|
||||||
|
msg: error.message ? error.message : "Unknown error",
|
||||||
|
};
|
||||||
|
return thunkApi.rejectWithValue(payload);
|
||||||
}
|
}
|
||||||
const payload = {
|
|
||||||
status: false,
|
|
||||||
msg: error.message ? error.message : "Unknown error",
|
|
||||||
};
|
|
||||||
return thunkApi.rejectWithValue(payload);
|
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
export const login = createAsyncThunk("auth/login", async (form, thunkApi) => {
|
export const login = createAsyncThunk("auth/login", async (form, thunkApi) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -342,7 +342,6 @@ export const useDeleteMonitor = () => {
|
|||||||
const deleteMonitor = async ({ monitor, redirect }) => {
|
const deleteMonitor = async ({ monitor, redirect }) => {
|
||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
console.log(monitor);
|
|
||||||
await networkService.deleteMonitorById({ monitorId: monitor.id });
|
await networkService.deleteMonitorById({ monitorId: monitor.id });
|
||||||
createToast({ body: "Monitor deleted successfully!" });
|
createToast({ body: "Monitor deleted successfully!" });
|
||||||
if (redirect) {
|
if (redirect) {
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ const Register = ({ superAdminExists }) => {
|
|||||||
|
|
||||||
delete toSubmit.confirm;
|
delete toSubmit.confirm;
|
||||||
|
|
||||||
const action = await dispatch(register(toSubmit));
|
const action = await dispatch(register({ user: toSubmit, token }));
|
||||||
if (action.payload.success) {
|
if (action.payload.success) {
|
||||||
navigate("/uptime");
|
navigate("/uptime");
|
||||||
createToast({
|
createToast({
|
||||||
|
|||||||
@@ -143,7 +143,6 @@ const UptimeMonitors = () => {
|
|||||||
type: ["http", "ping", "docker", "port", "game"],
|
type: ["http", "ping", "docker", "port", "game"],
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(monitors);
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isSearching) {
|
if (isSearching) {
|
||||||
setPage(undefined);
|
setPage(undefined);
|
||||||
|
|||||||
@@ -347,17 +347,8 @@ class NetworkService {
|
|||||||
return this.axiosInstance.get(`/monitors/certificate/${config.monitorId}`);
|
return this.axiosInstance.get(`/monitors/certificate/${config.monitorId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
async registerUser(user, token) {
|
||||||
* ************************************
|
return this.axiosInstance.post(`/auth/register`, { user, token });
|
||||||
* Registers a new user
|
|
||||||
* ************************************
|
|
||||||
*
|
|
||||||
* @async
|
|
||||||
* @param {Object} form - The form data for the new user to be registered.
|
|
||||||
* @returns {Promise<AxiosResponse>} The response from the axios POST request.
|
|
||||||
*/
|
|
||||||
async registerUser(form) {
|
|
||||||
return this.axiosInstance.post(`/auth/register`, form);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user