Skip to content

Commit

Permalink
fix id search
Browse files Browse the repository at this point in the history
  • Loading branch information
oxdev03 committed Mar 23, 2024
1 parent 07655a6 commit 065bb11
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions apps/dashboard/middleware/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ObjectId } from "mongodb";
import { Document } from "mongoose";
import { NextApiRequest, NextApiResponse } from "next";
import { getToken } from "next-auth/jwt";
Expand All @@ -14,7 +13,7 @@ const authHandler =
await connectDB();
const token = await getToken({ req });
if (!token) return res.status(401).end();
const user = await UserModel.findOne({ _id: new ObjectId(token.sub) });
const user = await UserModel.findById(token.sub);
if (!user) return res.status(401).end();
return handler(req, res, user);
};
Expand Down

0 comments on commit 065bb11

Please sign in to comment.