mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
make sure the user owns the modified data
This commit is contained in:
@@ -100,6 +100,16 @@ public class FeedSubscriptionService extends GenericDAO<FeedSubscription> {
|
|||||||
return criteria.getResultList();
|
return criteria.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<FeedSubscription> findByCategory(User user,
|
||||||
|
FeedCategory category) {
|
||||||
|
EasyCriteria<FeedSubscription> criteria = EasyCriteriaFactory
|
||||||
|
.createQueryCriteria(em, getType());
|
||||||
|
criteria.andEquals(MF.i(proxy().getUser()), user);
|
||||||
|
criteria.andEquals(MF.i(proxy().getCategory()), category);
|
||||||
|
return criteria.getResultList();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public List<FeedSubscription> findWithoutCategories(User user) {
|
public List<FeedSubscription> findWithoutCategories(User user) {
|
||||||
EasyCriteria<FeedSubscription> criteria = EasyCriteriaFactory
|
EasyCriteria<FeedSubscription> criteria = EasyCriteriaFactory
|
||||||
.createQueryCriteria(em, getType());
|
.createQueryCriteria(em, getType());
|
||||||
|
|||||||
@@ -81,8 +81,14 @@ public class SubscriptionsREST extends AbstractREST {
|
|||||||
@GET
|
@GET
|
||||||
@Path("unsubscribe")
|
@Path("unsubscribe")
|
||||||
public Response unsubscribe(@QueryParam("id") Long subscriptionId) {
|
public Response unsubscribe(@QueryParam("id") Long subscriptionId) {
|
||||||
feedSubscriptionService.deleteById(subscriptionId);
|
FeedSubscription sub = feedSubscriptionService.findById(getUser(),
|
||||||
return Response.ok(Status.OK).build();
|
subscriptionId);
|
||||||
|
if (sub != null) {
|
||||||
|
feedSubscriptionService.delete(sub);
|
||||||
|
return Response.ok(Status.OK).build();
|
||||||
|
} else {
|
||||||
|
return Response.status(Status.NOT_FOUND).build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@@ -137,8 +143,19 @@ public class SubscriptionsREST extends AbstractREST {
|
|||||||
@GET
|
@GET
|
||||||
@Path("deleteCategory")
|
@Path("deleteCategory")
|
||||||
public Response deleteCategory(@QueryParam("id") Long id) {
|
public Response deleteCategory(@QueryParam("id") Long id) {
|
||||||
feedCategoryService.deleteById(id);
|
FeedCategory cat = feedCategoryService.findById(getUser(), id);
|
||||||
return Response.ok().build();
|
if (cat != null) {
|
||||||
|
List<FeedSubscription> subs = feedSubscriptionService
|
||||||
|
.findByCategory(getUser(), cat);
|
||||||
|
for (FeedSubscription sub : subs) {
|
||||||
|
sub.setCategory(null);
|
||||||
|
}
|
||||||
|
feedSubscriptionService.update(subs);
|
||||||
|
feedCategoryService.delete(cat);
|
||||||
|
return Response.ok().build();
|
||||||
|
} else {
|
||||||
|
return Response.status(Status.NOT_FOUND).build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<li>
|
<li>
|
||||||
<div ng-mouseenter="hovered=node" ng-mouseleave="hovered=null" class="pointer">
|
<div ng-mouseenter="hovered=node && node.id != 'all'" ng-mouseleave="hovered=null" class="pointer">
|
||||||
<div class="dropdown pull-right">
|
<div class="dropdown pull-right">
|
||||||
<a dropdown-toggle class="pull-right">
|
<a dropdown-toggle class="pull-right">
|
||||||
<i ng-show="hovered==node" class="icon icon-chevron-down"></i>
|
<i ng-show="hovered==node" class="icon icon-chevron-down"></i>
|
||||||
|
|||||||
@@ -149,6 +149,8 @@ module.directive('category', function($compile) {
|
|||||||
if (result == 'ok') {
|
if (result == 'ok') {
|
||||||
SubscriptionService.deleteCategory({
|
SubscriptionService.deleteCategory({
|
||||||
id : category.id
|
id : category.id
|
||||||
|
}, function() {
|
||||||
|
SubscriptionService.init();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user