Merge pull request #2529 from bluewave-labs/hotfix/delete-user
hotfix: delete user
This commit is contained in:
3 files changed
+15
-3
No files matched your search
@@ -412,8 +412,7 @@ class AuthController {
|
|||||||
// 1. Find all the monitors associated with the team ID if superadmin
|
// 1. Find all the monitors associated with the team ID if superadmin
|
||||||
|
|
||||||
const result = await this.db.getMonitorsByTeamId({
|
const result = await this.db.getMonitorsByTeamId({
|
||||||
query: {},
|
teamId: user.teamId.toString(),
|
||||||
params: { teamId: user.teamId.toString() },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (user.role.includes("superadmin")) {
|
if (user.role.includes("superadmin")) {
|
||||||
|
|||||||
@@ -1,15 +1,20 @@
|
|||||||
import logger from "../utils/logger.js";
|
import logger from "../utils/logger.js";
|
||||||
import ServiceRegistry from "../service/serviceRegistry.js";
|
import ServiceRegistry from "../service/serviceRegistry.js";
|
||||||
import StringService from "../service/stringService.js";
|
import StringService from "../service/stringService.js";
|
||||||
|
import { ObjectId } from "mongodb";
|
||||||
|
|
||||||
const SERVICE_NAME = "verifyOwnership";
|
const SERVICE_NAME = "verifyOwnership";
|
||||||
|
|
||||||
const verifyOwnership = (Model, paramName) => {
|
const verifyOwnership = (Model, paramName) => {
|
||||||
const stringService = ServiceRegistry.get(StringService.SERVICE_NAME);
|
const stringService = ServiceRegistry.get(StringService.SERVICE_NAME);
|
||||||
return async (req, res, next) => {
|
return async (req, res, next) => {
|
||||||
const userId = req.user._id;
|
const userId = req.user._id;
|
||||||
const documentId = req.params[paramName];
|
let documentId = req.params[paramName];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (typeof documentId === "string") {
|
||||||
|
documentId = ObjectId.createFromHexString(documentId);
|
||||||
|
}
|
||||||
const doc = await Model.findById(documentId);
|
const doc = await Model.findById(documentId);
|
||||||
//If the document is not found, return a 404 error
|
//If the document is not found, return a 404 error
|
||||||
if (!doc) {
|
if (!doc) {
|
||||||
|
|||||||
@@ -436,6 +436,14 @@ class StringService {
|
|||||||
get testEmailSubject() {
|
get testEmailSubject() {
|
||||||
return this.translationService.getTranslation("testEmailSubject");
|
return this.translationService.getTranslation("testEmailSubject");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get verifyOwnerNotFound() {
|
||||||
|
return this.translationService.getTranslation("verifyOwnerNotFound");
|
||||||
|
}
|
||||||
|
|
||||||
|
get verifyOwnerUnauthorized() {
|
||||||
|
return this.translationService.getTranslation("verifyOwnerUnauthorized");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default StringService;
|
export default StringService;
|
||||||
Reference in new issue
Block a user