Skip to content

Commit

Permalink
add code suger in profile
Browse files Browse the repository at this point in the history
  • Loading branch information
janishar committed Apr 2, 2020
1 parent 53139f0 commit 7bbf62f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/routes/v1/profile/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}));

Expand All @@ -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;
Expand Down

0 comments on commit 7bbf62f

Please sign in to comment.