Skip to content

Conversation

@pkol92
Copy link
Collaborator

@pkol92 pkol92 commented Mar 23, 2021

Add middleware

@pkol92 pkol92 requested review from farce1 and s-justina March 23, 2021 12:37
Comment on lines 24 to 26
this.router.get(`${this.path}/:userId`, authMiddleware, permissionMiddleware, this.getFavourites);
this.router.put(`${this.path}/:userId`, authMiddleware, permissionMiddleware, this.addOrRemoveRestaurantToFavourites);
this.router.get(`${this.path}/:userId`, authMiddleware, this.getFavourites);
this.router.put(`${this.path}/:userId`, authMiddleware, favourtieEditMiddleware, this.addOrRemoveRestaurantToFavourites);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's behind permissionMiddleware removal?

import commentDeleteMiddleware from '../middleware/commentDelete.middleware';
import commentEditMiddleware from '../middleware/editComment.middleware';

class CommentsController implements Controller {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a lot of code that we have to test.

try {
selectedComment = await comment.findById(commentId);
const commentOwner = selectedComment.user !== null && selectedComment.user;
if ( userRole === 2) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( userRole === 2) {
if ( userRole === userRoles.User) {

We have to make a map that will hold these numeric values

try {
const favourieListtId = request.params.userId;
const userId = request.user._id;
if ( userId.toString() !== favourieListtId.toString() ) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

favourieListtId -misspeled

userId.toString() !== favourieListtId.toString() - this can be extracted to const

@farce1 farce1 mentioned this pull request Mar 24, 2021
@farce1 farce1 self-requested a review April 11, 2021 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants