diff --git a/src/routes/v1/profile/user.ts b/src/routes/v1/profile/user.ts index ac6c775..9caaa8d 100644 --- a/src/routes/v1/profile/user.ts +++ b/src/routes/v1/profile/user.ts @@ -15,7 +15,7 @@ const router = express.Router(); router.get('/public/id/:id', validator(schema.userId, ValidationSource.PARAM), asyncHandler(async (req: ProtectedRequest, res, next) => { const user = await UserRepo.findPublicProfileById(new Types.ObjectId(req.params.id)); - if (user == null) throw new BadRequestError('User not registered'); + if (!user) throw new BadRequestError('User not registered'); return new SuccessResponse('success', _.pick(user, ['name', 'profilePicUrl'])).send(res); })); @@ -27,14 +27,14 @@ router.use('/', authentication); router.get('/my', asyncHandler(async (req: ProtectedRequest, res, next) => { const user = await UserRepo.findProfileById(req.user._id); - if (user == null) throw new BadRequestError('User not registered'); + if (!user) throw new BadRequestError('User not registered'); return new SuccessResponse('success', _.pick(user, ['name', 'profilePicUrl', 'roles'])).send(res); })); router.put('/', validator(schema.profile), asyncHandler(async (req: ProtectedRequest, res, next) => { const user = await UserRepo.findProfileById(req.user._id); - if (user == null) throw new BadRequestError('User not registered'); + if (!user) throw new BadRequestError('User not registered'); if (req.body.name) user.name = req.body.name; if (req.body.profilePicUrl) user.profilePicUrl = req.body.profilePicUrl;