handling all of the stuff with header logout and handling better jwttoken
This commit is contained in:
@@ -26,7 +26,6 @@ export const authCheck = async (
|
||||
|
||||
next();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
res.status(401).send("unauthorized");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -43,8 +43,6 @@ async function handleAuthCheck(req: Request, res: Response) {
|
||||
|
||||
async function getUserDetails(req: Request, res: Response) {
|
||||
try {
|
||||
console.log(res.locals.userInfo as JwtClaims);
|
||||
|
||||
const userInfo = res.locals.userInfo as JwtClaims;
|
||||
|
||||
const user = await UserService.getUserById(userInfo.userId);
|
||||
|
||||
@@ -7,7 +7,7 @@ import { collections } from "./database.service";
|
||||
|
||||
export class UserService {
|
||||
static async getUserById(userId: string) {
|
||||
const query = { _id: userId };
|
||||
const query = { _id: new ObjectId(userId) };
|
||||
|
||||
const res = await collections.users?.findOne(query);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user