aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorSun Howwrongbum <sun@adrenosapient.com>2016-11-24 04:41:30 +0530
committerSun Howwrongbum <sun@adrenosapient.com>2016-11-24 04:41:30 +0530
commit73a8eb4f267615d865c2c2c5c0f462da983dd0a5 (patch)
treefba8deb7cf8ab665d7c035e00a4b65e7e430b1fa /src/org
parentdbbe99269140f057d3f72acca557730a6b10e902 (diff)
downloadtraccar-server-73a8eb4f267615d865c2c2c5c0f462da983dd0a5.tar.gz
traccar-server-73a8eb4f267615d865c2c2c5c0f462da983dd0a5.tar.bz2
traccar-server-73a8eb4f267615d865c2c2c5c0f462da983dd0a5.zip
Add option to set some default User properties
- for `deviceLimit` and `expirationTime`.
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/api/resource/UserResource.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/org/traccar/api/resource/UserResource.java b/src/org/traccar/api/resource/UserResource.java
index ddbca6b0f..bbbe465fc 100644
--- a/src/org/traccar/api/resource/UserResource.java
+++ b/src/org/traccar/api/resource/UserResource.java
@@ -16,6 +16,7 @@
package org.traccar.api.resource;
import org.traccar.Context;
+import org.traccar.Config;
import org.traccar.api.BaseResource;
import org.traccar.model.User;
@@ -32,6 +33,8 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.sql.SQLException;
import java.util.Collection;
+import java.util.Date;
+import java.util.Calendar;
@Path("users")
@Produces(MediaType.APPLICATION_JSON)
@@ -50,6 +53,18 @@ public class UserResource extends BaseResource {
if (!Context.getPermissionsManager().isAdmin(getUserId())) {
Context.getPermissionsManager().checkRegistration(getUserId());
Context.getPermissionsManager().checkUserUpdate(getUserId(), new User(), entity);
+ Config config = Context.getConfig();
+ int deviceLimit = config.getInteger("default.deviceLimit");
+ int expirationDuration = config.getInteger("default.expirationDuration");
+ if (deviceLimit > 0) {
+ entity.setDeviceLimit(deviceLimit);
+ }
+ if (expirationDuration > 0) {
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DATE, expirationDuration);
+ Date expirationTime = cal.getTime();
+ entity.setExpirationTime(expirationTime);
+ }
}
Context.getPermissionsManager().addUser(entity);
if (Context.getNotificationManager() != null) {