Work around authentication check blocking-call bug in Quarkus 1.10.x.
A bug causes authentication checks to fail when performed from inside
a reactive operation:
https://github.com/quarkusio/quarkus/issues/13835
To avoid such a reactive operation, we now render the HTML template
eagerly even in NewsletterResource#register, which is otherwise a
reactive implementation.
Change-Id: I26d6c1cc76eaa041a04c106b7cf06f024a0cded3
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterResource.java b/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterResource.java
index a46ee32..85af008 100644
--- a/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterResource.java
+++ b/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterResource.java
@@ -40,14 +40,14 @@
@POST
@Path("register")
@Transactional
- public CompletionStage<TemplateInstance> register(@FormParam("email") String email) {
+ public CompletionStage<String> register(@FormParam("email") String email) {
var existingSubscription =
NewsletterSubscription.<NewsletterSubscription>find("email = ?1", email)
.singleResultOptional();
if (existingSubscription.isPresent()) {
// If a subscription already exists, act as if we had created it. This provides better
// privacy to users than an error message does.
- return CompletableFuture.completedStage(Templates.completeRegistration());
+ return CompletableFuture.completedStage(Templates.completeRegistration().render());
}
var subscription = new NewsletterSubscription();
@@ -56,7 +56,8 @@
var mailText = Templates.registrationMail(subscription.registrationKey);
var sendJob = mailText.subject("MulkCMS newsletter registration").to(email).send();
- return sendJob.thenApply((x) -> Templates.completeRegistration());
+ var page = Templates.completeRegistration().render();
+ return sendJob.thenApply((x) -> page);
}
@GET