Properly create new access tokens
This commit is contained in:
parent
021d448c15
commit
1c9983de66
@ -59,27 +59,24 @@ public final class POSTDeploymentUpdateServer implements Handler<RoutingContext>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Server server = Server.findById(serverId);
|
Server server = Server.findById(serverId);
|
||||||
|
AccessToken accessToken = SyncUtils.runBlocking(v -> AccessToken.findByNameAndType(serverId, type, v));
|
||||||
|
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
server = new Server(serverId, displayName, group, ip + ":" + port);
|
server = new Server(serverId, displayName, group, ip + ":" + port);
|
||||||
SyncUtils.<Void>runBlocking(server::insert);
|
accessToken = new AccessToken(server);
|
||||||
|
|
||||||
|
SyncUtils.runBlocking(server::insert);
|
||||||
|
SyncUtils.runBlocking(accessToken::insert);
|
||||||
} else {
|
} else {
|
||||||
server.setServerIp(ip + ":" + port);
|
server.setServerIp(ip + ":" + port);
|
||||||
server.setLastUpdatedAt(Instant.now());
|
server.setLastUpdatedAt(Instant.now());
|
||||||
SyncUtils.<Void>runBlocking(server::save);
|
SyncUtils.runBlocking(server::save);
|
||||||
|
|
||||||
|
accessToken.setLockedIps(ImmutableList.of(ip));
|
||||||
|
accessToken.setLastUpdatedAt(Instant.now());
|
||||||
|
SyncUtils.runBlocking(accessToken::save);
|
||||||
}
|
}
|
||||||
|
|
||||||
AccessToken accessToken = SyncUtils.runBlocking(v -> AccessToken.findByNameAndType(serverId, type, v));
|
|
||||||
|
|
||||||
if (accessToken == null) {
|
|
||||||
ErrorUtils.respondNotFound(ctx, "access token", serverId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
accessToken.setLockedIps(ImmutableList.of(ip));
|
|
||||||
accessToken.setLastUpdatedAt(Instant.now());
|
|
||||||
|
|
||||||
SyncUtils.<Void>runBlocking(accessToken::save);
|
|
||||||
ctx.response().end(accessToken.getId());
|
ctx.response().end(accessToken.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user