Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
A-nirvana committed Nov 11, 2024
1 parent 9e705a4 commit f22176c
Show file tree
Hide file tree
Showing 9 changed files with 210 additions and 72 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
"dotenv": "^16.4.5",
"eslint-config-airbnb": "^19.0.4",
"jsonwebtoken": "^9.0.2",

"moment-timezone": "^0.5.46",
"moment-timezone": "^0.5.46",
"mongoose": "^8.7.2",
"next": "14.1.0",
"next-pwa": "^5.6.0",
"nodemailer": "^6.9.16",
"otplib": "^12.0.1",
"react": "^18",
"react-dom": "^18",
"sass": "^1.71.1",
"typescript": "^5.6.3"
"typescript": "^5.6.3",
"zod": "^3.23.8"
},
"devDependencies": {
"@types/react": "18.3.2",
Expand Down
105 changes: 89 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/app/api/v1/makeAdmin/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from "next/server";
import mongoose from "mongoose";
import dbConnect from "../../../../../lib/dbConnect";
import UserModel from "../../../../../model/User";
import { isSuperAdmin } from "../../../../../helpers/verifyAdmin";
Expand All @@ -21,6 +22,13 @@ export async function POST(req: NextRequest) {
);
}

if (!mongoose.isValidObjectId(id)) {
return NextResponse.json(
{ message: "Invalid User ID format" },
{ status: 400 },
);
}

try {
const user = await UserModel.findByIdAndUpdate(
id,
Expand Down
8 changes: 8 additions & 0 deletions src/app/api/v1/makeClient/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from "next/server";
import mongoose from "mongoose";
import dbConnect from "../../../../../lib/dbConnect";
import UserModel from "../../../../../model/User";
import { isSuperAdmin } from "../../../../../helpers/verifyAdmin";
Expand All @@ -21,6 +22,13 @@ export async function POST(req: NextRequest) {
);
}

if (!mongoose.isValidObjectId(id)) {
return NextResponse.json(
{ message: "Invalid User ID format" },
{ status: 400 },
);
}

try {
const user = await UserModel.findByIdAndUpdate(
id,
Expand Down
Loading

0 comments on commit f22176c

Please sign in to comment.