aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-11-18 00:16:55 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-11-18 00:16:55 +1300
commit468e3b0aa03fbe69b4c590743cf9f6886ef99751 (patch)
tree5a663969b2701f3a8d092fc43437754ceda81cfa /src/org/traccar/database
parentaf6c734879aa483efcc8150d5fdb704f40fb59cd (diff)
downloadtrackermap-server-468e3b0aa03fbe69b4c590743cf9f6886ef99751.tar.gz
trackermap-server-468e3b0aa03fbe69b4c590743cf9f6886ef99751.tar.bz2
trackermap-server-468e3b0aa03fbe69b4c590743cf9f6886ef99751.zip
Check account on every call
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r--src/org/traccar/database/PermissionsManager.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java
index e620d5334..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,8 +227,8 @@ public class PermissionsManager {
public User login(String email, String password) throws SQLException {
User user = dataManager.login(email, password);
- if (user != null && !user.getDisabled() && (user.getExpirationTime() == null
- || user.getExpirationTime().getTime() > System.currentTimeMillis())) {
+ if (user != null) {
+ checkUser(user.getId());
return users.get(user.getId());
}
return null;