mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-04-27 12:09:29 -05:00
early return if user not found
This commit is contained in:
@@ -80,6 +80,7 @@ UserSchema.pre("findOneAndUpdate", function (next) {
|
||||
UserSchema.pre("findOneAndDelete", async function (next) {
|
||||
try {
|
||||
const userToDelete = await this.model.findOne(this.getFilter());
|
||||
if (!userToDelete) return next();
|
||||
if (userToDelete.role.includes("superadmin")) {
|
||||
await Team.deleteOne({ _id: userToDelete.teamId });
|
||||
await Monitor.deleteMany({ userId: userToDelete._id });
|
||||
|
||||
Reference in New Issue
Block a user