diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-16 07:45:19 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-16 07:45:19 -0700 |
commit | e74c64f27dc30473d9ef866c5c52e3dd6bee2fc3 (patch) | |
tree | 00ff1a6d2debb857aef0c736d3a68b2607b45ab9 /src/main/java/org/traccar/api/security | |
parent | cc342a9ba371b0dca8d87ca9e74c5907ccb58bc6 (diff) | |
download | trackermap-server-e74c64f27dc30473d9ef866c5c52e3dd6bee2fc3.tar.gz trackermap-server-e74c64f27dc30473d9ef866c5c52e3dd6bee2fc3.tar.bz2 trackermap-server-e74c64f27dc30473d9ef866c5c52e3dd6bee2fc3.zip |
Refactor device permissions check
Diffstat (limited to 'src/main/java/org/traccar/api/security')
-rw-r--r-- | src/main/java/org/traccar/api/security/PermissionsService.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/api/security/PermissionsService.java b/src/main/java/org/traccar/api/security/PermissionsService.java index f39ded2b7..8732a0d04 100644 --- a/src/main/java/org/traccar/api/security/PermissionsService.java +++ b/src/main/java/org/traccar/api/security/PermissionsService.java @@ -92,6 +92,19 @@ public class PermissionsService { } } + public void checkUserEnabled(long userId) throws StorageException, SecurityException { + User user = getUser(userId); + if (user == null) { + throw new SecurityException("Unknown account"); + } + if (user.getDisabled()) { + throw new SecurityException("Account is disabled"); + } + if (user.getExpirationTime() != null && System.currentTimeMillis() > user.getExpirationTime().getTime()) { + throw new SecurityException("Account has expired"); + } + } + public void checkEdit(long userId, Class<?> clazz, boolean addition) throws StorageException, SecurityException { if (!getUser(userId).getAdministrator()) { boolean denied = false; |