aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/http/DeviceServlet.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-06-13 17:36:31 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-06-13 17:36:31 +1200
commitfc75fe4ab4f8ea9de58c41772fdd92c10c73f2bc (patch)
tree9418ef08d1b5d8858922b90e4c0b9e2f1747b2ee /src/org/traccar/http/DeviceServlet.java
parentbd4c32abced2bb654b64a2042668340167d6b191 (diff)
downloadtrackermap-server-fc75fe4ab4f8ea9de58c41772fdd92c10c73f2bc.tar.gz
trackermap-server-fc75fe4ab4f8ea9de58c41772fdd92c10c73f2bc.tar.bz2
trackermap-server-fc75fe4ab4f8ea9de58c41772fdd92c10c73f2bc.zip
Fix API access permissions
Diffstat (limited to 'src/org/traccar/http/DeviceServlet.java')
-rw-r--r--src/org/traccar/http/DeviceServlet.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/org/traccar/http/DeviceServlet.java b/src/org/traccar/http/DeviceServlet.java
index 1387c2a13..1e8e1f047 100644
--- a/src/org/traccar/http/DeviceServlet.java
+++ b/src/org/traccar/http/DeviceServlet.java
@@ -40,25 +40,27 @@ public class DeviceServlet extends BaseServlet {
private void get(HttpServletRequest req, HttpServletResponse resp) throws Exception {
sendResponse(resp.getWriter(), JsonConverter.arrayToJson(
- Context.getDataManager().getDevices(getUserId(req.getSession()))));
+ Context.getDataManager().getDevices(getUserId(req))));
}
private void add(HttpServletRequest req, HttpServletResponse resp) throws Exception {
Device device = JsonConverter.objectFromJson(req.getReader(), new Device());
Context.getDataManager().addDevice(device);
- Context.getDataManager().linkDevice(getUserId(req.getSession()), device.getId());
+ Context.getDataManager().linkDevice(getUserId(req), device.getId());
sendResponse(resp.getWriter(), JsonConverter.objectToJson(device));
}
private void update(HttpServletRequest req, HttpServletResponse resp) throws Exception {
- Context.getDataManager().updateDevice(JsonConverter.objectFromJson(
- req.getReader(), new Device()));
+ Device device = JsonConverter.objectFromJson(req.getReader(), new Device());
+ Context.getPermissionsManager().checkDevice(getUserId(req), device.getId());
+ Context.getDataManager().updateDevice(device);
sendResponse(resp.getWriter(), true);
}
private void remove(HttpServletRequest req, HttpServletResponse resp) throws Exception {
- Context.getDataManager().removeDevice(JsonConverter.objectFromJson(
- req.getReader(), new Device()));
+ Device device = JsonConverter.objectFromJson(req.getReader(), new Device());
+ Context.getPermissionsManager().checkDevice(getUserId(req), device.getId());
+ Context.getDataManager().removeDevice(device);
sendResponse(resp.getWriter(), true);
}