Skip to content

Commit

Permalink
Work around authentication check blocking-call bug in Quarkus 1.10.x.
Browse files Browse the repository at this point in the history
A bug causes authentication checks to fail when performed from inside
a reactive operation:

    quarkusio/quarkus#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
  • Loading branch information
benkard committed Dec 17, 2020
1 parent a743872 commit 4db0854
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ public TemplateInstance getIndex() {
@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();
Expand All @@ -56,7 +56,8 @@ public CompletionStage<TemplateInstance> register(@FormParam("email") String ema

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
Expand Down

0 comments on commit 4db0854

Please sign in to comment.