mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-24 13:39:35 +02:00
Backend: auth for bookmarks and categories
This commit is contained in:
parent
22471d64c7
commit
0d36c5cf94
6 changed files with 39 additions and 12 deletions
|
@ -12,15 +12,20 @@ const getAllCategories = asyncWrapper(async (req, res, next) => {
|
|||
|
||||
let categories;
|
||||
|
||||
// categories visibility
|
||||
const where = req.isAuthenticated ? {} : { isPublic: true };
|
||||
|
||||
if (orderType == 'name') {
|
||||
categories = await Category.findAll({
|
||||
include: [
|
||||
{
|
||||
model: Bookmark,
|
||||
as: 'bookmarks',
|
||||
where,
|
||||
},
|
||||
],
|
||||
order: [[Sequelize.fn('lower', Sequelize.col('Category.name')), 'ASC']],
|
||||
where,
|
||||
});
|
||||
} else {
|
||||
categories = await Category.findAll({
|
||||
|
@ -28,9 +33,11 @@ const getAllCategories = asyncWrapper(async (req, res, next) => {
|
|||
{
|
||||
model: Bookmark,
|
||||
as: 'bookmarks',
|
||||
where,
|
||||
},
|
||||
],
|
||||
order: [[orderType, 'ASC']],
|
||||
where,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue