hotfix permissions

This commit is contained in:
_Bastler 2024-01-02 16:41:13 +01:00
parent ebe0d67780
commit bcb235d9ea

View File

@ -420,12 +420,11 @@ public class PermissionManager implements UserDataProvider {
List<Permission> existingPermissions = get(target, name); List<Permission> existingPermissions = get(target, name);
for (Permission existingPermission : existingPermissions) { for (Permission existingPermission : existingPermissions) {
if (additional && existingPermission.getExpires().isAfter(Instant.now()) if (additional && (starts == null && (existingPermission.getStarts() == null
&& (starts == null && (existingPermission.getStarts() == null || existingPermission.getStarts().isBefore(Instant.now()))
|| existingPermission.getStarts().isBefore(Instant.now())) || starts != null && (starts.isBefore(existingPermission.getExpires())
|| starts != null && (starts.isBefore(existingPermission.getExpires()) || existingPermission.getStarts() != null
|| existingPermission.getStarts() != null && starts.isAfter(existingPermission.getStarts())))) {
&& starts.isAfter(existingPermission.getStarts())))) {
if (permission == null) { if (permission == null) {
permission = existingPermission; permission = existingPermission;
} else if (existingPermission.getExpires().isAfter(permission.getExpires())) { } else if (existingPermission.getExpires().isAfter(permission.getExpires())) {
@ -441,8 +440,6 @@ public class PermissionManager implements UserDataProvider {
permission.setAddon(permissionMapping.isAddon()); permission.setAddon(permissionMapping.isAddon());
permission.setStarts(permissionStarts); permission.setStarts(permissionStarts);
permission.setExpires(permissionsExpires); permission.setExpires(permissionsExpires);
logger.debug("now: " + Instant.now() + "\nstart: " + permissionStarts + "\nexpires here: "
+ permission.getExpires());
} else { } else {
if (permission.getExpires() == null || permission.getExpires().isBefore(Instant.now())) { if (permission.getExpires() == null || permission.getExpires().isBefore(Instant.now())) {
permission.setExpires(Instant.now()); permission.setExpires(Instant.now());
@ -460,10 +457,6 @@ public class PermissionManager implements UserDataProvider {
permission.setExpires( permission.setExpires(
InstantHelper.truncate(permission.getExpires(), permissionMapping.getLifetimeUnit())); InstantHelper.truncate(permission.getExpires(), permissionMapping.getLifetimeUnit()));
} }
logger.debug("Permission: \n" + permission.getName() + "\n" + permission.getId() + "\n"
+ permission.getTarget() + "\n" + permission.getStarts() + "\n" + permission.getExpires());
permissions.add(permission); permissions.add(permission);
} }
} }