From e278f0c5ecd1eb2442a8f2367212cdb57c1da1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Tr=C3=A9guier?= Date: Fri, 29 Nov 2024 11:17:30 +0100 Subject: [PATCH] Fix email verification link --- src/main/java/app/fyreplace/api/emails/EmailBase.java | 6 ++++-- .../app/fyreplace/api/emails/EmailVerificationEmail.java | 5 +++++ .../app/fyreplace/api/emails/UserActivationEmail.java | 2 +- .../app/fyreplace/api/emails/UserConnectionEmail.java | 2 +- src/main/java/app/fyreplace/api/emails/UserEmailBase.java | 8 ++++++++ 5 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 src/main/java/app/fyreplace/api/emails/UserEmailBase.java diff --git a/src/main/java/app/fyreplace/api/emails/EmailBase.java b/src/main/java/app/fyreplace/api/emails/EmailBase.java index 69f9e38..3b873e4 100644 --- a/src/main/java/app/fyreplace/api/emails/EmailBase.java +++ b/src/main/java/app/fyreplace/api/emails/EmailBase.java @@ -47,11 +47,13 @@ public abstract class EmailBase extends Mail { @Context UriInfo uriInfo; + protected Email email; + private boolean customDeepLinks; private String randomCodeClearText; - private Email email; + protected abstract String path(); protected abstract String action(); @@ -87,7 +89,7 @@ protected String getRandomCode() { protected String getLink() { return UriBuilder.fromUri(appFrontUrl.toString()) .scheme(customDeepLinks ? appFrontCustomScheme : appFrontUrl.getScheme()) - .path(email.user.active ? "/login" : "/register") + .path(path()) .queryParam("action", action()) .fragment(getRandomCode()) .build() diff --git a/src/main/java/app/fyreplace/api/emails/EmailVerificationEmail.java b/src/main/java/app/fyreplace/api/emails/EmailVerificationEmail.java index df00a5b..bf47418 100644 --- a/src/main/java/app/fyreplace/api/emails/EmailVerificationEmail.java +++ b/src/main/java/app/fyreplace/api/emails/EmailVerificationEmail.java @@ -6,6 +6,11 @@ @RequestScoped public final class EmailVerificationEmail extends EmailBase { + @Override + protected String path() { + return "/settings/emails"; + } + @Override protected String action() { return "email"; diff --git a/src/main/java/app/fyreplace/api/emails/UserActivationEmail.java b/src/main/java/app/fyreplace/api/emails/UserActivationEmail.java index de517ae..1d8bf7a 100644 --- a/src/main/java/app/fyreplace/api/emails/UserActivationEmail.java +++ b/src/main/java/app/fyreplace/api/emails/UserActivationEmail.java @@ -5,7 +5,7 @@ import jakarta.enterprise.context.RequestScoped; @RequestScoped -public final class UserActivationEmail extends EmailBase { +public final class UserActivationEmail extends UserEmailBase { @Override protected String action() { return "connect"; diff --git a/src/main/java/app/fyreplace/api/emails/UserConnectionEmail.java b/src/main/java/app/fyreplace/api/emails/UserConnectionEmail.java index 3bf4fa5..656867a 100644 --- a/src/main/java/app/fyreplace/api/emails/UserConnectionEmail.java +++ b/src/main/java/app/fyreplace/api/emails/UserConnectionEmail.java @@ -5,7 +5,7 @@ import jakarta.enterprise.context.RequestScoped; @RequestScoped -public final class UserConnectionEmail extends EmailBase { +public final class UserConnectionEmail extends UserEmailBase { @Override protected String action() { return "connect"; diff --git a/src/main/java/app/fyreplace/api/emails/UserEmailBase.java b/src/main/java/app/fyreplace/api/emails/UserEmailBase.java new file mode 100644 index 0000000..78a1136 --- /dev/null +++ b/src/main/java/app/fyreplace/api/emails/UserEmailBase.java @@ -0,0 +1,8 @@ +package app.fyreplace.api.emails; + +public abstract class UserEmailBase extends EmailBase { + @Override + protected String path() { + return email.user.active ? "/login" : "/register"; + } +}