mirror of
https://github.com/Athou/commafeed.git
synced 2026-11-05 03:44:47 +00:00
prevent users from referencing categories owned by other users
This commit is contained in:
@@ -39,6 +39,7 @@ import jakarta.validation.Valid;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.NotFoundException;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
@@ -333,8 +334,10 @@ public class CategoryREST {
|
||||
cat.setPosition(0);
|
||||
String parentId = req.getParentId();
|
||||
if (parentId != null && !ALL.equals(parentId)) {
|
||||
FeedCategory parent = new FeedCategory();
|
||||
parent.setId(Long.valueOf(parentId));
|
||||
FeedCategory parent = feedCategoryDAO.findById(user, Long.valueOf(parentId));
|
||||
if (parent == null) {
|
||||
throw new NotFoundException("parent category not found");
|
||||
}
|
||||
cat.setParent(parent);
|
||||
}
|
||||
feedCategoryDAO.persist(cat);
|
||||
|
||||
@@ -407,13 +407,17 @@ public class FeedREST {
|
||||
Preconditions.checkNotNull(req.getUrl());
|
||||
|
||||
try {
|
||||
User user = authenticationContext.getCurrentUser();
|
||||
|
||||
FeedCategory category = null;
|
||||
if (req.getCategoryId() != null && !CategoryREST.ALL.equals(req.getCategoryId())) {
|
||||
category = feedCategoryDAO.findById(Long.valueOf(req.getCategoryId()));
|
||||
category = feedCategoryDAO.findById(user, Long.valueOf(req.getCategoryId()));
|
||||
if (category == null) {
|
||||
return Response.status(Status.NOT_FOUND).build();
|
||||
}
|
||||
}
|
||||
|
||||
FeedInfo info = fetchFeedInternal(prependHttp(req.getUrl()));
|
||||
User user = authenticationContext.getCurrentUser();
|
||||
long subscriptionId = feedSubscriptionService.subscribe(user, info.getUrl(), req.getTitle(), category, 0);
|
||||
return Response.ok(subscriptionId).build();
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user