How to pass URL parameter from service layer to thymeleaf template?

情到浓时终转凉″ 提交于 2021-01-29 09:37:55

问题


I'm working on an e-mail template that has a "Confirm Registration" button redirects the user to a token related url that will validate the users registration proccess.

Confirm registration button :

<a href="" target="_blank">CONFIRM REGISTRATION</a>

SendVerificationToken method that's creating the confirmationUrl :

public void sendVerificationToken(User user) {
    String token = jwtTokenService.genEmailVerificationToken(user.getId());
    logger.info("Sending verification token to user. user={} email={} token={}",
            user.getId(), user.getEmail(), token);
    String confirmationUrl = null;
    try {
        confirmationUrl = new URIBuilder(verifyEmailUrl)
                .addParameter(VERIFY_EMAIL_ENDPOINT_PARAM, token)
                .build().toString();
    }

    catch (URISyntaxException e) {
        logger.error("URL stored as redirect url for verify email is not valid.");
        throw ErrorFactory.serverError("Error");
    }
    emailService.sendAccountConfirmationEmail(user.getEmail(), confirmationUrl);
}

I wanna know how do I pass the confirmationUrl parameter from the sendVerificationToken method to the "Confirm Registration" button. Would appreciate if someone could help me with this one. Thank you.

来源:https://stackoverflow.com/questions/65293021/how-to-pass-url-parameter-from-service-layer-to-thymeleaf-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!