Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class ProductItemComponent implements OnInit {
addToWishlist(id: string) {
if (this.currentUser) {
this.productService.addWishlist(id).subscribe((res) => {
this.item.wishlist = true;
alert(res?.message || 'Added');
}, (err) => {
alert(err?.message || 'Unable to process');
Expand All @@ -41,6 +42,7 @@ export class ProductItemComponent implements OnInit {
removeFromWishlist(id: string) {
if (this.currentUser) {
this.productService.removeFromWishlist(id).subscribe((res) => {
this.item.wishlist = false;
alert(res?.message || 'Removed');
}, (err) => {
alert(err?.message || 'Unable to process');
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/pages/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class LoginComponent implements OnInit {
}
}, (err) => {
console.log('err', err);
this.msg = err.body?.message || 'Unable to process request!';
this.msg = err || 'Unable to process request!';
});

}
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ services:
MONGODB_SERVER_STATIC: localhost
MONGODB_URI: mongodb//mongo_db:27017,
JWT_SECRET: skfjslkjksdfjw3434j32l4
JWT_EXPIRES_IN: 3600000
JWT_EXPIRES_IN: 365d
ports:
- "5000:5000"
volumes:
Expand Down
3 changes: 1 addition & 2 deletions server/components/wishlist/WishlistRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ router.delete('/:id', async (req, res, next) => {
if (!req.authenticatedUser) {
return next(new AuthenticationException('Unauthorized'));
}

try {
await WishlistService.deleteHoax(req.params.hoaxId, req.authenticatedUser.id);
await WishlistService.deleteItem(req.params.id, req.authenticatedUser);
res.send();
} catch (err) {
return next(err);
Expand Down
6 changes: 5 additions & 1 deletion server/components/wishlist/WishlistService.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,15 @@ const getItemsWithProducts = async (page, size, authenticatedUser) => {
};
};

const deleteItem = async (productId, authenticatedUser) => {
return await Wishlist.findOne({ user: ObjectId(authenticatedUser._id), product: ObjectId(productId) }).remove().exec();
};

module.exports = {
save,
findByUserIdAndProductId,
getItem,
getItems,
getItemsWithProducts
getItemsWithProducts,
deleteItem
};
3 changes: 2 additions & 1 deletion server/config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
},
JWT: {
JWT_SECRET: process.env.JWT_SECRET || 'thetokenwillbereplaced',
JWT_EXPIRES_IN: process.env.JWT_EXPIRES_IN || 3600000
//JWT_EXPIRES_IN: process.env.JWT_EXPIRES_IN || '365d'
JWT_EXPIRES_IN: '365d'
}
};