diff --git a/server/controllers/authController.js b/server/controllers/authController.js index 5538e996d..d517c50d9 100755 --- a/server/controllers/authController.js +++ b/server/controllers/authController.js @@ -412,8 +412,7 @@ class AuthController { // 1. Find all the monitors associated with the team ID if superadmin const result = await this.db.getMonitorsByTeamId({ - query: {}, - params: { teamId: user.teamId.toString() }, + teamId: user.teamId.toString(), }); if (user.role.includes("superadmin")) { diff --git a/server/middleware/verifyOwnership.js b/server/middleware/verifyOwnership.js index 011b178a4..2040d54ee 100755 --- a/server/middleware/verifyOwnership.js +++ b/server/middleware/verifyOwnership.js @@ -1,15 +1,20 @@ import logger from "../utils/logger.js"; import ServiceRegistry from "../service/serviceRegistry.js"; import StringService from "../service/stringService.js"; +import { ObjectId } from "mongodb"; + const SERVICE_NAME = "verifyOwnership"; const verifyOwnership = (Model, paramName) => { const stringService = ServiceRegistry.get(StringService.SERVICE_NAME); return async (req, res, next) => { const userId = req.user._id; - const documentId = req.params[paramName]; + let documentId = req.params[paramName]; try { + if (typeof documentId === "string") { + documentId = ObjectId.createFromHexString(documentId); + } const doc = await Model.findById(documentId); //If the document is not found, return a 404 error if (!doc) { diff --git a/server/service/stringService.js b/server/service/stringService.js index 499aa769f..5ee17a5ef 100755 --- a/server/service/stringService.js +++ b/server/service/stringService.js @@ -436,6 +436,14 @@ class StringService { get testEmailSubject() { return this.translationService.getTranslation("testEmailSubject"); } + + get verifyOwnerNotFound() { + return this.translationService.getTranslation("verifyOwnerNotFound"); + } + + get verifyOwnerUnauthorized() { + return this.translationService.getTranslation("verifyOwnerUnauthorized"); + } } export default StringService;