aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-11-24 15:33:36 +1300
committerGitHub <noreply@github.com>2016-11-24 15:33:36 +1300
commit7269b9b32ef8f75fc0fbd1c64d4d4748c731ce04 (patch)
tree66b1a03e771e76196a879940e1917bf9bd1e50d5
parent15d54b086be597f5698acc5750694f93c7629ca7 (diff)
parenta1ad3e264293cf58bb77992e143b0d7c1c2cef96 (diff)
downloadtrackermap-server-7269b9b32ef8f75fc0fbd1c64d4d4748c731ce04.tar.gz
trackermap-server-7269b9b32ef8f75fc0fbd1c64d4d4748c731ce04.tar.bz2
trackermap-server-7269b9b32ef8f75fc0fbd1c64d4d4748c731ce04.zip
Merge pull request #2595 from sunhoww/default_user_props
Add option to set some default User properties
-rw-r--r--src/org/traccar/api/resource/UserResource.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/org/traccar/api/resource/UserResource.java b/src/org/traccar/api/resource/UserResource.java
index ddbca6b0f..678daac9b 100644
--- a/src/org/traccar/api/resource/UserResource.java
+++ b/src/org/traccar/api/resource/UserResource.java
@@ -32,6 +32,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.sql.SQLException;
import java.util.Collection;
+import java.util.Date;
@Path("users")
@Produces(MediaType.APPLICATION_JSON)
@@ -50,6 +51,12 @@ public class UserResource extends BaseResource {
if (!Context.getPermissionsManager().isAdmin(getUserId())) {
Context.getPermissionsManager().checkRegistration(getUserId());
Context.getPermissionsManager().checkUserUpdate(getUserId(), new User(), entity);
+ entity.setDeviceLimit(Context.getConfig().getInteger("users.defaultDeviceLimit"));
+ int expirationDays = Context.getConfig().getInteger("users.defaultExpirationDays");
+ if (expirationDays > 0) {
+ entity.setExpirationTime(
+ new Date(System.currentTimeMillis() + (long) expirationDays * 24 * 3600 * 1000));
+ }
}
Context.getPermissionsManager().addUser(entity);
if (Context.getNotificationManager() != null) {