Change POST /grants|ipBans|punishments to use expiresIn
(a relative field in seconds) instead of expiresAt
(absolute time)
This commit is contained in:
parent
6fbc8925eb
commit
53a56401e0
@ -65,8 +65,9 @@ public final class POSTGrants implements Handler<RoutingContext> {
|
||||
|
||||
Instant expiresAt = null;
|
||||
|
||||
if (requestBody.containsKey("expiresAt") && requestBody.getLong("expiresAt") != -1) {
|
||||
expiresAt = Instant.ofEpochMilli(requestBody.getLong("expiresAt"));
|
||||
if (requestBody.containsKey("expiresIn") && requestBody.getLong("expiresIn") != -1) {
|
||||
long expiresInMillis = requestBody.getLong("expiresIn") * 1000;
|
||||
expiresAt = Instant.ofEpochMilli(System.currentTimeMillis() + expiresInMillis);
|
||||
}
|
||||
|
||||
if (expiresAt != null && expiresAt.isBefore(Instant.now())) {
|
||||
|
@ -35,8 +35,9 @@ public final class POSTIpBans implements Handler<RoutingContext> {
|
||||
|
||||
Instant expiresAt = null;
|
||||
|
||||
if (requestBody.containsKey("expiresAt") && requestBody.getLong("expiresAt") != -1) {
|
||||
expiresAt = Instant.ofEpochMilli(requestBody.getLong("expiresAt"));
|
||||
if (requestBody.containsKey("expiresIn") && requestBody.getLong("expiresIn") != -1) {
|
||||
long expiresInMillis = requestBody.getLong("expiresIn") * 1000;
|
||||
expiresAt = Instant.ofEpochMilli(System.currentTimeMillis() + expiresInMillis);
|
||||
}
|
||||
|
||||
if (expiresAt != null && expiresAt.isBefore(Instant.now())) {
|
||||
|
@ -63,8 +63,9 @@ public final class POSTPunishments implements Handler<RoutingContext> {
|
||||
|
||||
Instant expiresAt = null;
|
||||
|
||||
if (requestBody.containsKey("expiresAt") && requestBody.getLong("expiresAt") != -1) {
|
||||
expiresAt = Instant.ofEpochMilli(requestBody.getLong("expiresAt"));
|
||||
if (requestBody.containsKey("expiresIn") && requestBody.getLong("expiresIn") != -1) {
|
||||
long expiresInMillis = requestBody.getLong("expiresIn") * 1000;
|
||||
expiresAt = Instant.ofEpochMilli(System.currentTimeMillis() + expiresInMillis);
|
||||
}
|
||||
|
||||
if (expiresAt != null && expiresAt.isBefore(Instant.now())) {
|
||||
|
Loading…
Reference in New Issue
Block a user