Skip to content

Commit

Permalink
Fix email verification link
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentTreguier committed Dec 6, 2024
1 parent c58f026 commit e278f0c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/main/java/app/fyreplace/api/emails/EmailBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

@RequestScoped
public final class EmailVerificationEmail extends EmailBase {
@Override
protected String path() {
return "/settings/emails";
}

@Override
protected String action() {
return "email";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/app/fyreplace/api/emails/UserEmailBase.java
Original file line number Diff line number Diff line change
@@ -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";
}
}

0 comments on commit e278f0c

Please sign in to comment.