aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-11-18 19:12:25 +1300
committerGitHub <noreply@github.com>2016-11-18 19:12:25 +1300
commit3eca9acd6e6a160df8f7b86150429c3d7c09b0c3 (patch)
treecb8bc7293a5c3fbac7f5e7557c73baded57109d8 /src/org/traccar/database
parentf04881e56938315867a97db2027d58f27f7a20fd (diff)
parentf35da3ffdf6f960a877149b72b819a1979c9395a (diff)
downloadtrackermap-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/database')
-rw-r--r--src/org/traccar/database/PermissionsManager.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java
index b0ae504d0..1c995a11d 100644
--- a/src/org/traccar/database/PermissionsManager.java
+++ b/src/org/traccar/database/PermissionsManager.java
@@ -146,7 +146,17 @@ public class PermissionsManager {
public void checkReadonly(long userId) throws SecurityException {
if (!isAdmin(userId) && (server.getReadonly() || isReadonly(userId))) {
- throw new SecurityException("User is readonly");
+ throw new SecurityException("Account is readonly");
+ }
+ }
+
+ public void checkUser(long userId) throws SecurityException {
+ User user = getUser(userId);
+ if (user.getDisabled()) {
+ throw new SecurityException("Account is disabled");
+ }
+ if (user.getExpirationTime() != null && System.currentTimeMillis() > user.getExpirationTime().getTime()) {
+ throw new SecurityException("Account has expired");
}
}
@@ -217,11 +227,11 @@ public class PermissionsManager {
public User login(String email, String password) throws SQLException {
User user = dataManager.login(email, password);
- if (user != null && users.get(user.getId()) != null) {
+ if (user != null) {
+ checkUser(user.getId());
return users.get(user.getId());
- } else {
- return null;
}
+ return null;
}
}