From ce200eeb20a4da2a860ef7a5b4a294b95443dfea Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 16 Jul 2024 14:06:51 -0700 Subject: [PATCH 1/3] Reset password returns a token --- Server/controllers/authController.js | 4 ++-- Server/db/MongoDB.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Server/controllers/authController.js b/Server/controllers/authController.js index 979a0b87e..a4fe598d1 100644 --- a/Server/controllers/authController.js +++ b/Server/controllers/authController.js @@ -309,11 +309,11 @@ const validateRecoveryTokenController = async (req, res, next) => { const resetPasswordController = async (req, res, next) => { try { await newPasswordValidation.validateAsync(req.body); - user = await req.db.resetPassword(req, res); + const token = await req.db.resetPassword(req, res); res.status(200).json({ success: true, msg: successMessages.AUTH_RESET_PASSWORD, - data: user, + data: token, }); } catch (error) { error.service = SERVICE_NAME; diff --git a/Server/db/MongoDB.js b/Server/db/MongoDB.js index c0b0948a2..1170134de 100644 --- a/Server/db/MongoDB.js +++ b/Server/db/MongoDB.js @@ -220,7 +220,8 @@ const resetPassword = async (req, res) => { }) .select("-password") .select("-profileImage"); - return userWithoutPassword; + const token = issueToken(userWithoutPassword); + return token; } else { throw new Error(errorMessages.DB_USER_NOT_FOUND); } From 6ddbbdc1226c8c3b455eef575d6405e18084bcec Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 16 Jul 2024 14:16:45 -0700 Subject: [PATCH 2/3] Cleanup --- Client/src/Components/Host/index.jsx | 18 ----- Client/src/Components/HostActions/index.jsx | 8 --- Client/src/Components/HostStatus/index.jsx | 18 ----- Client/src/Components/HostsTable/index.jsx | 80 --------------------- Client/src/Pages/Details/index.jsx | 1 - 5 files changed, 125 deletions(-) delete mode 100644 Client/src/Components/Host/index.jsx delete mode 100644 Client/src/Components/HostActions/index.jsx delete mode 100644 Client/src/Components/HostStatus/index.jsx delete mode 100644 Client/src/Components/HostsTable/index.jsx diff --git a/Client/src/Components/Host/index.jsx b/Client/src/Components/Host/index.jsx deleted file mode 100644 index 370745f4d..000000000 --- a/Client/src/Components/Host/index.jsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from "react"; -import OpenIt from "../../assets/Images/Icon-open-in-tab-gray.png"; - -function Host(title, precentage, statusColor, link) { - return ( -
- - OpenIt - -
{title}
-
- {precentage}% -
-
- ); -} - -export default Host; diff --git a/Client/src/Components/HostActions/index.jsx b/Client/src/Components/HostActions/index.jsx deleted file mode 100644 index c974906e8..000000000 --- a/Client/src/Components/HostActions/index.jsx +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import DashboardSettings from "../DashboardSettingsIcon"; - -function HostActions() { - return ; -} - -export default HostActions; diff --git a/Client/src/Components/HostStatus/index.jsx b/Client/src/Components/HostStatus/index.jsx deleted file mode 100644 index 3b0660c33..000000000 --- a/Client/src/Components/HostStatus/index.jsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from "react"; - -function HostStatus(backgroundColor, status, dotColor) { - return ( -
-
-
{status}
-
- ); -} - -export default HostStatus; diff --git a/Client/src/Components/HostsTable/index.jsx b/Client/src/Components/HostsTable/index.jsx deleted file mode 100644 index bc1dc1ff9..000000000 --- a/Client/src/Components/HostsTable/index.jsx +++ /dev/null @@ -1,80 +0,0 @@ -import PropTypes from "prop-types"; -import Host from "../Host/"; -import HostStatus from "../HostStatus"; -import ResponseTimeChart from "../Charts/ResponseTimeChart"; -/** - * HostsTable displays the current status of monitor - * - * @component - * @param {Array} monitors - An array of monitor objects to be displayed. - */ - -const getLastCheckStatus = (monitor) => { - if (monitor.checks.length === 0) { - // Default values for when there are no checks - return { - color: "var(--env-var-color-21)", - statusText: "No Data", - dotColor: "var(--env-var-color-19)", - }; - } - - const lastCheck = monitor.checks[monitor.checks.length - 1]; - const isUp = lastCheck.status === true; - return { - color: isUp ? "var(--env-var-color-20)" : "var(--env-var-color-21)", - statusText: isUp ? "Up" : "Down", - dotColor: isUp ? "var(--env-var-color-17)" : "var(--env-var-color-19)", - }; -}; - -const HostsTable = ({ monitors }) => { - return ( -
- - - - - - - - - - - {monitors.map((monitor) => { - const host = Host( - monitor.name, - 100, - "var(--env-var-color-17)", - monitor.url - ); - - const { color, currentStatus, dotColor } = - getLastCheckStatus(monitor); - - const status = HostStatus(color, currentStatus, dotColor); - - return ( - - - - - - - ); - })} - -
HostStatusResponseActions
{host}{status} - - - {monitor.actions} -
-
- ); -}; - -HostsTable.propTypes = { - monitors: PropTypes.arrayOf(PropTypes.object).isRequired, -}; - -export default HostsTable; diff --git a/Client/src/Pages/Details/index.jsx b/Client/src/Pages/Details/index.jsx index 201a32524..c8cd6be7a 100644 --- a/Client/src/Pages/Details/index.jsx +++ b/Client/src/Pages/Details/index.jsx @@ -1,5 +1,4 @@ import React, { useEffect, useState } from "react"; -import CustomizedTables from "../../Components/CustomizedTables"; import { Box, Typography, useTheme } from "@mui/material"; import { useSelector } from "react-redux"; import { useParams } from "react-router-dom"; From 61d65f700ee4bbe1c1492b16098a8e0b89de21f1 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 16 Jul 2024 14:23:42 -0700 Subject: [PATCH 3/3] Add user to response --- Server/controllers/authController.js | 4 ++-- Server/db/MongoDB.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Server/controllers/authController.js b/Server/controllers/authController.js index a4fe598d1..51ee2dac1 100644 --- a/Server/controllers/authController.js +++ b/Server/controllers/authController.js @@ -309,11 +309,11 @@ const validateRecoveryTokenController = async (req, res, next) => { const resetPasswordController = async (req, res, next) => { try { await newPasswordValidation.validateAsync(req.body); - const token = await req.db.resetPassword(req, res); + const response = await req.db.resetPassword(req, res); res.status(200).json({ success: true, msg: successMessages.AUTH_RESET_PASSWORD, - data: token, + data: response, }); } catch (error) { error.service = SERVICE_NAME; diff --git a/Server/db/MongoDB.js b/Server/db/MongoDB.js index 1170134de..4b225b543 100644 --- a/Server/db/MongoDB.js +++ b/Server/db/MongoDB.js @@ -221,7 +221,7 @@ const resetPassword = async (req, res) => { .select("-password") .select("-profileImage"); const token = issueToken(userWithoutPassword); - return token; + return { user: userWithoutPassword, token: token }; } else { throw new Error(errorMessages.DB_USER_NOT_FOUND); }