diff options
-rw-r--r-- | src/org/traccar/api/resource/UserResource.java | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/org/traccar/api/resource/UserResource.java b/src/org/traccar/api/resource/UserResource.java index bbbe465fc..5f940ebf1 100644 --- a/src/org/traccar/api/resource/UserResource.java +++ b/src/org/traccar/api/resource/UserResource.java @@ -16,7 +16,6 @@ package org.traccar.api.resource; import org.traccar.Context; -import org.traccar.Config; import org.traccar.api.BaseResource; import org.traccar.model.User; @@ -34,7 +33,6 @@ 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) @@ -53,17 +51,12 @@ 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); + int deviceLimit = Context.getConfig().getInteger("users.defaultDeviceLimit"); + int expirationDays = Context.getConfig().getInteger("users.defaultExpirationDays"); + entity.setDeviceLimit(deviceLimit); + if (expirationDays > 0) { + entity.setExpirationTime( + new Date(System.currentTimeMillis() + (long) expirationDays * 24 * 3600 * 1000)); } } Context.getPermissionsManager().addUser(entity); |