diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-11-18 19:12:25 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-18 19:12:25 +1300 |
commit | 3eca9acd6e6a160df8f7b86150429c3d7c09b0c3 (patch) | |
tree | cb8bc7293a5c3fbac7f5e7557c73baded57109d8 /src/org/traccar/api/resource/DeviceResource.java | |
parent | f04881e56938315867a97db2027d58f27f7a20fd (diff) | |
parent | f35da3ffdf6f960a877149b72b819a1979c9395a (diff) | |
download | trackermap-server-3eca9acd6e6a160df8f7b86150429c3d7c09b0c3.tar.gz trackermap-server-3eca9acd6e6a160df8f7b86150429c3d7c09b0c3.tar.bz2 trackermap-server-3eca9acd6e6a160df8f7b86150429c3d7c09b0c3.zip |
Merge pull request #2548 from tananaev/users
Add user expiration and device limit
Diffstat (limited to 'src/org/traccar/api/resource/DeviceResource.java')
-rw-r--r-- | src/org/traccar/api/resource/DeviceResource.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/org/traccar/api/resource/DeviceResource.java b/src/org/traccar/api/resource/DeviceResource.java index f20ed86ad..0b389ede1 100644 --- a/src/org/traccar/api/resource/DeviceResource.java +++ b/src/org/traccar/api/resource/DeviceResource.java @@ -58,6 +58,13 @@ public class DeviceResource extends BaseResource { @POST public Response add(Device entity) throws SQLException { Context.getPermissionsManager().checkReadonly(getUserId()); + int deviceLimit = Context.getPermissionsManager().getUser(getUserId()).getDeviceLimit(); + if (deviceLimit != 0) { + int deviceCount = Context.getPermissionsManager().getDevicePermissions(getUserId()).size(); + if (deviceCount >= deviceLimit) { + throw new SecurityException("User device limit reached"); + } + } Context.getDeviceManager().addDevice(entity); Context.getDataManager().linkDevice(getUserId(), entity.getId()); Context.getPermissionsManager().refreshPermissions(); |