Don't run SyncUtils.runBlocking methods in AuditLog callbacks (these callbacks are ran on an event loop thread)
This commit is contained in:
parent
79a9f7770c
commit
694394a670
@ -37,6 +37,8 @@ public final class POSTDisposableLoginTokensIdUse implements Handler<RoutingCont
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String session = SyncUtils.runBlocking(v -> UserSessionUtils.createSession(user.getId(), userIp, v));
|
||||||
|
|
||||||
AuditLog.log(user.getId(), userIp, ctx, AuditLogActionType.DISPOSABLE_LOGIN_TOKEN_USE, (ignored, error2) -> {
|
AuditLog.log(user.getId(), userIp, ctx, AuditLogActionType.DISPOSABLE_LOGIN_TOKEN_USE, (ignored, error2) -> {
|
||||||
if (error2 != null) {
|
if (error2 != null) {
|
||||||
ErrorUtils.respondInternalError(ctx, error2);
|
ErrorUtils.respondInternalError(ctx, error2);
|
||||||
@ -46,8 +48,8 @@ public final class POSTDisposableLoginTokensIdUse implements Handler<RoutingCont
|
|||||||
APIv3.respondJson(ctx, 200, ImmutableMap.of(
|
APIv3.respondJson(ctx, 200, ImmutableMap.of(
|
||||||
"authorized", true,
|
"authorized", true,
|
||||||
"uuid", user.getId(),
|
"uuid", user.getId(),
|
||||||
"session", SyncUtils.<String>runBlocking(v -> UserSessionUtils.createSession(user.getId(), userIp, v))
|
"session", session)
|
||||||
));
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.frozenorb.apiv3.route.users;
|
package net.frozenorb.apiv3.route.users;
|
||||||
|
|
||||||
|
import com.mongodb.async.SingleResultCallback;
|
||||||
import io.vertx.core.Handler;
|
import io.vertx.core.Handler;
|
||||||
import io.vertx.ext.web.RoutingContext;
|
import io.vertx.ext.web.RoutingContext;
|
||||||
import net.frozenorb.apiv3.APIv3;
|
import net.frozenorb.apiv3.APIv3;
|
||||||
@ -50,18 +51,31 @@ public final class GETUsersIdVerifyPassword implements Handler<RoutingContext> {
|
|||||||
AuditLog.log(user.getId(), userIp, ctx, authorized ? AuditLogActionType.USER_LOGIN_SUCCESS : AuditLogActionType.USER_LOGIN_FAIL, (ignored, error) -> {
|
AuditLog.log(user.getId(), userIp, ctx, authorized ? AuditLogActionType.USER_LOGIN_SUCCESS : AuditLogActionType.USER_LOGIN_FAIL, (ignored, error) -> {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
ErrorUtils.respondInternalError(ctx, error);
|
ErrorUtils.respondInternalError(ctx, error);
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SingleResultCallback<String> responseCallback = (session, sessionError) -> {
|
||||||
|
if (sessionError != null) {
|
||||||
|
ErrorUtils.respondInternalError(ctx, sessionError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
|
||||||
result.put("authorized", authorized);
|
result.put("authorized", authorized);
|
||||||
result.put("uuid", finalUuid);
|
result.put("uuid", finalUuid);
|
||||||
|
|
||||||
if (authorized) {
|
if (authorized) {
|
||||||
String session = SyncUtils.runBlocking(v -> UserSessionUtils.createSession(finalUuid, userIp, v));
|
|
||||||
result.put("session", session);
|
result.put("session", session);
|
||||||
}
|
}
|
||||||
|
|
||||||
APIv3.respondJson(ctx, 200, result);
|
APIv3.respondJson(ctx, 200, result);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (authorized) {
|
||||||
|
UserSessionUtils.createSession(finalUuid, userIp, responseCallback);
|
||||||
|
} else {
|
||||||
|
responseCallback.onResult(null, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user